Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1726972

[PATCH 2/2] ALSA: rme9652: Use common error handling code in snd_hdspm_probe()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 2/2] ALSA: rme9652: Use common error handling code in snd_hdspm_probe()
Date 2017-09-05 22:40 +0200
Message-ID <umsNz-7IG-13@gated-at.bofh.it> (permalink)
References <umsNz-7IG-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 5 Sep 2017 22:22:21 +0200

Add a jump target so that a bit of exception handling can be better reused
at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/rme9652/hdspm.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 25284d8d9758..f20d42714e4d 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -6949,10 +6949,8 @@ static int snd_hdspm_probe(struct pci_dev *pci,
 	hdspm->pci = pci;
 
 	err = snd_hdspm_create(card, hdspm);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto free_card;
 
 	if (hdspm->io_type != MADIface) {
 		snprintf(card->shortname, sizeof(card->shortname), "%s_%x",
@@ -6970,15 +6968,17 @@ static int snd_hdspm_probe(struct pci_dev *pci,
 	}
 
 	err = snd_card_register(card);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto free_card;
 
 	pci_set_drvdata(pci, card);
 
 	dev++;
 	return 0;
+
+free_card:
+	snd_card_free(card);
+	return err;
 }
 
 static void snd_hdspm_remove(struct pci_dev *pci)
-- 
2.14.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] ALSA: rme9652: Adjustments for two function  implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-05 22:40 +0200
  [PATCH 2/2] ALSA: rme9652: Use common error handling code in  snd_hdspm_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-05 22:40 +0200
    Re: [PATCH 2/2] ALSA: rme9652: Use common error handling code in snd_hdspm_probe() Takashi Iwai <tiwai@suse.de> - 2017-09-07 10:30 +0200
  [PATCH 1/2] ALSA: rme9652: Use common code in  hdsp_get_iobox_version() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-05 22:40 +0200
    Re: [PATCH 1/2] ALSA: rme9652: Use common code in hdsp_get_iobox_version() Takashi Iwai <tiwai@suse.de> - 2017-09-07 10:30 +0200

csiph-web