aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/rawmidi.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index 091405385e15..70d6f25ba526 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -272,8 +272,10 @@ static int open_substream(struct snd_rawmidi *rmidi,
272 if (err < 0) 272 if (err < 0)
273 return err; 273 return err;
274 err = substream->ops->open(substream); 274 err = substream->ops->open(substream);
275 if (err < 0) 275 if (err < 0) {
276 snd_rawmidi_runtime_free(substream);
276 return err; 277 return err;
278 }
277 substream->opened = 1; 279 substream->opened = 1;
278 substream->active_sensing = 0; 280 substream->active_sensing = 0;
279 if (mode & SNDRV_RAWMIDI_LFLG_APPEND) 281 if (mode & SNDRV_RAWMIDI_LFLG_APPEND)
@@ -300,27 +302,27 @@ static int rawmidi_open_priv(struct snd_rawmidi *rmidi, int subdevice, int mode,
300 SNDRV_RAWMIDI_STREAM_INPUT, 302 SNDRV_RAWMIDI_STREAM_INPUT,
301 mode, &sinput); 303 mode, &sinput);
302 if (err < 0) 304 if (err < 0)
303 goto __error; 305 return err;
304 } 306 }
305 if (mode & SNDRV_RAWMIDI_LFLG_OUTPUT) { 307 if (mode & SNDRV_RAWMIDI_LFLG_OUTPUT) {
306 err = assign_substream(rmidi, subdevice, 308 err = assign_substream(rmidi, subdevice,
307 SNDRV_RAWMIDI_STREAM_OUTPUT, 309 SNDRV_RAWMIDI_STREAM_OUTPUT,
308 mode, &soutput); 310 mode, &soutput);
309 if (err < 0) 311 if (err < 0)
310 goto __error; 312 return err;
311 } 313 }
312 314
313 if (sinput) { 315 if (sinput) {
314 err = open_substream(rmidi, sinput, mode); 316 err = open_substream(rmidi, sinput, mode);
315 if (err < 0) 317 if (err < 0)
316 goto __error; 318 return err;
317 } 319 }
318 if (soutput) { 320 if (soutput) {
319 err = open_substream(rmidi, soutput, mode); 321 err = open_substream(rmidi, soutput, mode);
320 if (err < 0) { 322 if (err < 0) {
321 if (sinput) 323 if (sinput)
322 close_substream(rmidi, sinput, 0); 324 close_substream(rmidi, sinput, 0);
323 goto __error; 325 return err;
324 } 326 }
325 } 327 }
326 328
@@ -328,13 +330,6 @@ static int rawmidi_open_priv(struct snd_rawmidi *rmidi, int subdevice, int mode,
328 rfile->input = sinput; 330 rfile->input = sinput;
329 rfile->output = soutput; 331 rfile->output = soutput;
330 return 0; 332 return 0;
331
332 __error:
333 if (sinput && sinput->runtime)
334 snd_rawmidi_runtime_free(sinput);
335 if (soutput && soutput->runtime)
336 snd_rawmidi_runtime_free(soutput);
337 return err;
338} 333}
339 334
340/* called from sound/core/seq/seq_midi.c */ 335/* called from sound/core/seq/seq_midi.c */