mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ALSA: emu10k1: Use common error handling code in snd_emu10k1_playback_open()
@ 2026-06-18 10:56 Markus Elfring
  2026-06-18 15:50 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2026-06-18 10:56 UTC (permalink / raw)
  To: linux-sound, Clemens Ladisch, Jaroslav Kysela, Kees Cook, Takashi Iwai
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 18 Jun 2026 12:24:36 +0200

Use an additional label so that a bit of exception handling can be better
reused at the end of this function implementation.

This issue was detected by using the Coccinelle software.

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

diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c
index 9023f3444d20..b8749e0131ad 100644
--- a/sound/pci/emu10k1/emupcm.c
+++ b/sound/pci/emu10k1/emupcm.c
@@ -1181,19 +1181,17 @@ static int snd_emu10k1_playback_open(struct snd_pcm_substream *substream)
 	runtime->private_free = snd_emu10k1_pcm_free_substream;
 	runtime->hw = snd_emu10k1_playback;
 	err = snd_emu10k1_playback_set_constraints(runtime);
-	if (err < 0) {
-		kfree(epcm);
-		return err;
-	}
+	if (err < 0)
+		goto free_epcm;
+
 	if (emu->card_capabilities->emu_model)
 		sample_rate = emu->emu1010.word_clock;
 	else
 		sample_rate = 48000;
 	err = snd_pcm_hw_rule_noresample(runtime, sample_rate);
-	if (err < 0) {
-		kfree(epcm);
-		return err;
-	}
+	if (err < 0)
+		goto free_epcm;
+
 	mix = &emu->pcm_mixer[substream->number];
 	for (i = 0; i < 8; i++)
 		mix->send_routing[0][i] = mix->send_routing[1][i] = mix->send_routing[2][i] = i;
@@ -1204,6 +1202,10 @@ static int snd_emu10k1_playback_open(struct snd_pcm_substream *substream)
 	mix->epcm = epcm;
 	snd_emu10k1_pcm_mixer_notify(emu, substream->number, 1);
 	return 0;
+
+free_epcm:
+	kfree(epcm);
+	return err;
 }
 
 static int snd_emu10k1_playback_close(struct snd_pcm_substream *substream)
-- 
2.54.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: emu10k1: Use common error handling code in snd_emu10k1_playback_open()
  2026-06-18 10:56 [PATCH] ALSA: emu10k1: Use common error handling code in snd_emu10k1_playback_open() Markus Elfring
@ 2026-06-18 15:50 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-06-18 15:50 UTC (permalink / raw)
  To: Markus Elfring
  Cc: linux-sound, Clemens Ladisch, Jaroslav Kysela, Kees Cook,
	Takashi Iwai, LKML, kernel-janitors

On Thu, 18 Jun 2026 12:56:04 +0200,
Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 18 Jun 2026 12:24:36 +0200
> 
> Use an additional label so that a bit of exception handling can be better
> reused at the end of this function implementation.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied now.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-18 15:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-18 10:56 [PATCH] ALSA: emu10k1: Use common error handling code in snd_emu10k1_playback_open() Markus Elfring
2026-06-18 15:50 ` Takashi Iwai

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®