Commit 8579d2d7 authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Takashi Iwai

sound: rawmidi: fix double init when opening MIDI device with O_APPEND

Commit 9a1b64ca in 2.6.30 moved the
substream initialization code to where it would be executed every time
the substream is opened.

This had the consequence that any further opening would drop and leak
the data in the existing buffer, and that the device driver's open
callback would be called multiple times, unexpectedly.
Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
Cc: <stable@kernel.org>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent dede17b8
...@@ -266,17 +266,19 @@ static int open_substream(struct snd_rawmidi *rmidi, ...@@ -266,17 +266,19 @@ static int open_substream(struct snd_rawmidi *rmidi,
{ {
int err; int err;
err = snd_rawmidi_runtime_create(substream); if (substream->use_count == 0) {
if (err < 0) err = snd_rawmidi_runtime_create(substream);
return err; if (err < 0)
err = substream->ops->open(substream); return err;
if (err < 0) err = substream->ops->open(substream);
return err; if (err < 0)
substream->opened = 1; return err;
if (substream->use_count++ == 0) substream->opened = 1;
substream->active_sensing = 0; substream->active_sensing = 0;
if (mode & SNDRV_RAWMIDI_LFLG_APPEND) if (mode & SNDRV_RAWMIDI_LFLG_APPEND)
substream->append = 1; substream->append = 1;
}
substream->use_count++;
rmidi->streams[substream->stream].substream_opened++; rmidi->streams[substream->stream].substream_opened++;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment