From: SF Markus Elfring <elfring@users.sourceforge.net>
To: alsa-devel@alsa-project.org, Bhumika Goyal <bhumirks@gmail.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 3/3] ALSA: es1968: Use common error handling code in snd_es1968_capture_open()
Date: Wed, 15 Nov 2017 10:30:37 +0100 [thread overview]
Message-ID: <28d6e644-fe54-ecd9-6a2a-efc855299faa@users.sourceforge.net> (raw)
In-Reply-To: <e1e9e0cc-0378-c2fe-015d-15555fd61a23@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 15 Nov 2017 09:30:00 +0100
Add jump targets so that a bit of exception handling can be better reused
at the end of this function.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/pci/es1968.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 7777ec583e20..fc45fab258c1 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -1589,23 +1589,20 @@ static int snd_es1968_capture_open(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime;
struct es1968 *chip = snd_pcm_substream_chip(substream);
struct esschan *es;
- int apu1, apu2;
+ int apu1, apu2, rc;
apu1 = snd_es1968_alloc_apu_pair(chip, ESM_APU_PCM_CAPTURE);
if (apu1 < 0)
return apu1;
apu2 = snd_es1968_alloc_apu_pair(chip, ESM_APU_PCM_RATECONV);
if (apu2 < 0) {
- snd_es1968_free_apu_pair(chip, apu1);
- return apu2;
+ rc = apu2;
+ goto free_first_pair;
}
es = kzalloc(sizeof(*es), GFP_KERNEL);
- if (!es) {
- snd_es1968_free_apu_pair(chip, apu1);
- snd_es1968_free_apu_pair(chip, apu2);
- return -ENOMEM;
- }
+ if (!es)
+ goto e_nomem;
es->apu[0] = apu1;
es->apu[1] = apu1 + 1;
@@ -1621,12 +1618,9 @@ static int snd_es1968_capture_open(struct snd_pcm_substream *substream)
/* get mixbuffer */
es->mixbuf = snd_es1968_new_memory(chip, ESM_MIXBUF_SIZE);
- if (!es->mixbuf) {
- snd_es1968_free_apu_pair(chip, apu1);
- snd_es1968_free_apu_pair(chip, apu2);
- kfree(es);
- return -ENOMEM;
- }
+ if (!es->mixbuf)
+ goto free_data;
+
memset(es->mixbuf->buf.area, 0, ESM_MIXBUF_SIZE);
runtime->private_data = es;
@@ -1640,6 +1634,15 @@ static int snd_es1968_capture_open(struct snd_pcm_substream *substream)
spin_unlock_irq(&chip->substream_lock);
return 0;
+
+free_data:
+ kfree(es);
+e_nomem:
+ rc = -ENOMEM;
+ snd_es1968_free_apu_pair(chip, apu2);
+free_first_pair:
+ snd_es1968_free_apu_pair(chip, apu1);
+ return rc;
}
static int snd_es1968_playback_close(struct snd_pcm_substream *substream)
--
2.15.0
prev parent reply other threads:[~2017-11-15 9:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-15 9:26 [PATCH 0/3] ALSA: es1968: Fine-tuning for seven function implementations SF Markus Elfring
2017-11-15 9:27 ` [PATCH 1/3] ALSA: es1968: Adjust 16 function calls together with a variable assignment SF Markus Elfring
2017-11-15 9:29 ` [PATCH 2/3] ALSA: es1968: Use common error handling code in two functions SF Markus Elfring
2017-11-15 9:30 ` 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=28d6e644-fe54-ecd9-6a2a-efc855299faa@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=alsa-devel@alsa-project.org \
--cc=bhumirks@gmail.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