From: SF Markus Elfring <elfring@users.sourceforge.net>
To: alsa-devel@alsa-project.org, Arnd Bergmann <arnd@arndb.de>,
Arvind Yadav <arvind.yadav.cs@gmail.com>,
Bhumika Goyal <bhumirks@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Mark Brown <broonie@kernel.org>,
Takashi Iwai <tiwai@suse.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/3] ALSA: hal2: Use common error handling code in hal2_probe()
Date: Sat, 11 Nov 2017 19:11:55 +0100 [thread overview]
Message-ID: <efebe781-a78c-5bec-f519-752d46661687@users.sourceforge.net> (raw)
In-Reply-To: <118a96d5-c52a-fd22-23d5-28f20de7ff22@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 11 Nov 2017 18:26:06 +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/mips/hal2.c | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c
index 37d378a26a50..30563d9aa5c8 100644
--- a/sound/mips/hal2.c
+++ b/sound/mips/hal2.c
@@ -887,21 +887,16 @@ static int hal2_probe(struct platform_device *pdev)
return err;
err = hal2_create(card, &chip);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
err = hal2_pcm_create(chip);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
+
err = hal2_mixer_create(chip);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
strcpy(card->driver, "SGI HAL2 Audio");
strcpy(card->shortname, "SGI HAL2 Audio");
@@ -910,12 +905,15 @@ static int hal2_probe(struct platform_device *pdev)
SGI_HPCDMA_IRQ);
err = snd_card_register(card);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
+
platform_set_drvdata(pdev, card);
return 0;
+
+free_card:
+ snd_card_free(card);
+ return err;
}
static int hal2_remove(struct platform_device *pdev)
--
2.15.0
next prev parent reply other threads:[~2017-11-11 18:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-11 18:10 [PATCH 0/3] ALSA: hal2: Fine-tuning for four function implementations SF Markus Elfring
2017-11-11 18:11 ` SF Markus Elfring [this message]
2017-11-11 18:13 ` [PATCH 2/3] ALSA: hal2: Improve a size determination in hal2_create() SF Markus Elfring
2017-11-28 6:49 ` Takashi Iwai
2017-11-11 18:15 ` [PATCH 3/3] ALSA: hal2: Fix a typo in two comment lines SF Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=efebe781-a78c-5bec-f519-752d46661687@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=alsa-devel@alsa-project.org \
--cc=arnd@arndb.de \
--cc=arvind.yadav.cs@gmail.com \
--cc=bhumirks@gmail.com \
--cc=broonie@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).