From: SF Markus Elfring <elfring@users.sourceforge.net>
To: alsa-devel@alsa-project.org, Bhumika Goyal <bhumirks@gmail.com>,
David Howells <dhowells@redhat.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 4/4] ALSA: riptide: Use common error handling code in snd_riptide_create()
Date: Fri, 17 Nov 2017 10:51:40 +0100 [thread overview]
Message-ID: <855689e0-dc52-0669-7394-ec7151658115@users.sourceforge.net> (raw)
In-Reply-To: <0eef2699-f28a-c1e0-9351-268b5eb7e0c1@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 17 Nov 2017 10:22:33 +0100
Add jump targets 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/riptide/riptide.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index 774fba5bba48..b1b834e1b614 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -1878,8 +1878,7 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci,
snd_printk(KERN_ERR
"Riptide: unable to grab region 0x%lx-0x%lx\n",
chip->port, chip->port + 64 - 1);
- snd_riptide_free(chip);
- return -EBUSY;
+ goto e_busy;
}
hwport = (struct riptideport *)chip->port;
UNSET_AIE(hwport);
@@ -1888,26 +1887,27 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci,
KBUILD_MODNAME, chip)) {
snd_printk(KERN_ERR "Riptide: unable to grab IRQ %d\n",
pci->irq);
- snd_riptide_free(chip);
- return -EBUSY;
+ goto e_busy;
}
chip->irq = pci->irq;
chip->device_id = pci->device;
pci_set_master(pci);
err = snd_riptide_initialize(chip);
- if (err < 0) {
- snd_riptide_free(chip);
- return err;
- }
+ if (err < 0)
+ goto free_sound_chip;
err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
- if (err < 0) {
- snd_riptide_free(chip);
- return err;
- }
+ if (err < 0)
+ goto free_sound_chip;
*rchip = chip;
return 0;
+
+e_busy:
+ err = -EBUSY;
+free_sound_chip:
+ snd_riptide_free(chip);
+ return err;
}
static void
--
2.15.0
prev parent reply other threads:[~2017-11-17 9:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-17 9:46 [PATCH 0/4] ALSA-Riptide: Fine-tuning for seven function implementations SF Markus Elfring
2017-11-17 9:47 ` [PATCH 1/4] ALSA: riptide: Adjust 13 function calls together with a variable assignment SF Markus Elfring
2017-11-17 9:49 ` [PATCH 2/4] ALSA: riptide: Delete an unnecessary variable initialisation in snd_riptide_proc_read() SF Markus Elfring
2017-11-17 9:50 ` [PATCH 3/4] ALSA: riptide: Reduce the scope for two variables " SF Markus Elfring
2017-11-17 9:51 ` SF Markus Elfring [this message]
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=855689e0-dc52-0669-7394-ec7151658115@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=alsa-devel@alsa-project.org \
--cc=bhumirks@gmail.com \
--cc=dhowells@redhat.com \
--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
Powered by JetHome