diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2009-10-21 03:09:38 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-11-10 10:20:43 -0500 |
commit | 8579d2d7779d7ff41ea2a0183015e0e5038f1043 (patch) | |
tree | a194af444f11846d078ca3fb87bdb61f5188464e /sound | |
parent | dede17b8e931eeaa38b0288e8d545d558d904942 (diff) |
sound: rawmidi: fix double init when opening MIDI device with O_APPEND
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>
Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/core/rawmidi.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index c0adc14c91f0..3071e6f5801e 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c | |||
@@ -266,17 +266,19 @@ static int open_substream(struct snd_rawmidi *rmidi, | |||
266 | { | 266 | { |
267 | int err; | 267 | int err; |
268 | 268 | ||
269 | err = snd_rawmidi_runtime_create(substream); | 269 | if (substream->use_count == 0) { |
270 | if (err < 0) | 270 | err = snd_rawmidi_runtime_create(substream); |
271 | return err; | 271 | if (err < 0) |
272 | err = substream->ops->open(substream); | 272 | return err; |
273 | if (err < 0) | 273 | err = substream->ops->open(substream); |
274 | return err; | 274 | if (err < 0) |
275 | substream->opened = 1; | 275 | return err; |
276 | if (substream->use_count++ == 0) | 276 | substream->opened = 1; |
277 | substream->active_sensing = 0; | 277 | substream->active_sensing = 0; |
278 | if (mode & SNDRV_RAWMIDI_LFLG_APPEND) | 278 | if (mode & SNDRV_RAWMIDI_LFLG_APPEND) |
279 | substream->append = 1; | 279 | substream->append = 1; |
280 | } | ||
281 | substream->use_count++; | ||
280 | rmidi->streams[substream->stream].substream_opened++; | 282 | rmidi->streams[substream->stream].substream_opened++; |
281 | return 0; | 283 | return 0; |
282 | } | 284 | } |