Skip to content

Commit b59aff6

Browse files
elfringtiwai
authored andcommitted
ALSA: emu10k1: Use common error handling code in snd_emu10k1_playback_open()
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> Link: https://patch.msgid.link/d709474d-62b0-4f7e-9011-a0f716b35383@web.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 348f693 commit b59aff6

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

sound/pci/emu10k1/emupcm.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,19 +1181,17 @@ static int snd_emu10k1_playback_open(struct snd_pcm_substream *substream)
11811181
runtime->private_free = snd_emu10k1_pcm_free_substream;
11821182
runtime->hw = snd_emu10k1_playback;
11831183
err = snd_emu10k1_playback_set_constraints(runtime);
1184-
if (err < 0) {
1185-
kfree(epcm);
1186-
return err;
1187-
}
1184+
if (err < 0)
1185+
goto free_epcm;
1186+
11881187
if (emu->card_capabilities->emu_model)
11891188
sample_rate = emu->emu1010.word_clock;
11901189
else
11911190
sample_rate = 48000;
11921191
err = snd_pcm_hw_rule_noresample(runtime, sample_rate);
1193-
if (err < 0) {
1194-
kfree(epcm);
1195-
return err;
1196-
}
1192+
if (err < 0)
1193+
goto free_epcm;
1194+
11971195
mix = &emu->pcm_mixer[substream->number];
11981196
for (i = 0; i < 8; i++)
11991197
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)
12041202
mix->epcm = epcm;
12051203
snd_emu10k1_pcm_mixer_notify(emu, substream->number, 1);
12061204
return 0;
1205+
1206+
free_epcm:
1207+
kfree(epcm);
1208+
return err;
12071209
}
12081210

12091211
static int snd_emu10k1_playback_close(struct snd_pcm_substream *substream)

0 commit comments

Comments
 (0)