mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ALSA: cs5530: Use common error handling code in snd_cs5530_probe()
@ 2017-11-18 21:15 SF Markus Elfring
  0 siblings, 0 replies; only message in thread
From: SF Markus Elfring @ 2017-11-18 21:15 UTC (permalink / raw)
  To: alsa-devel, Jaroslav Kysela, Takashi Iwai; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 18 Nov 2017 22:10:19 +0100

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/cs5530.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/sound/pci/cs5530.c b/sound/pci/cs5530.c
index 0a8cf94c4858..674572edf2d2 100644
--- a/sound/pci/cs5530.c
+++ b/sound/pci/cs5530.c
@@ -269,23 +269,24 @@ static int snd_cs5530_probe(struct pci_dev *pci,
 		return err;
 
 	err = snd_cs5530_create(card, pci, &chip);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto free_card;
 
 	strcpy(card->driver, "CS5530");
 	strcpy(card->shortname, "CS5530 Audio");
 	sprintf(card->longname, "%s at 0x%lx", card->shortname, chip->pci_base);
 
 	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 struct pci_driver cs5530_driver = {
-- 
2.15.0

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-11-18 21:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-18 21:15 [PATCH] ALSA: cs5530: Use common error handling code in snd_cs5530_probe() SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®