summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2009-10-21 09:09:38 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-08 10:21:06 -0800
commitdfe0b47c1e940dbe2f59133c08c485dee78668c5 (patch)
tree758d4d9800d8305c1e4e567ad04c14ee805a3904 /sound
parent1a65ef117b0bcb58f5e8b97dc477728e98d3a795 (diff)
sound: rawmidi: fix double init when opening MIDI device with O_APPEND
commit 8579d2d7779d7ff41ea2a0183015e0e5038f1043 upstream. Commit 9a1b64caac82aa02cb74587ffc798e6f42c6170a 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: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/core/rawmidi.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index b583959e9c0d..091405385e15 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -267,17 +267,19 @@ static int open_substream(struct snd_rawmidi *rmidi,
{
int err;
- err = snd_rawmidi_runtime_create(substream);
- if (err < 0)
- return err;
- err = substream->ops->open(substream);
- if (err < 0)
- return err;
- substream->opened = 1;
- if (substream->use_count++ == 0)
+ if (substream->use_count == 0) {
+ err = snd_rawmidi_runtime_create(substream);
+ if (err < 0)
+ return err;
+ err = substream->ops->open(substream);
+ if (err < 0)
+ return err;
+ substream->opened = 1;
substream->active_sensing = 0;
- if (mode & SNDRV_RAWMIDI_LFLG_APPEND)
- substream->append = 1;
+ if (mode & SNDRV_RAWMIDI_LFLG_APPEND)
+ substream->append = 1;
+ }
+ substream->use_count++;
rmidi->streams[substream->stream].substream_opened++;
return 0;
}