From: Clemens Ladisch Date: Wed, 21 Oct 2009 07:10:16 +0000 (+0200) Subject: sound: rawmidi: fix checking of O_APPEND when opening MIDI device X-Git-Tag: v2.6.32-rc8~31^2~4 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=16fb109644b5644e42ececeff644514de6f4bd03;p=~shefty%2Frdma-dev.git sound: rawmidi: fix checking of O_APPEND when opening MIDI device Commit 9a1b64caac82aa02cb74587ffc798e6f42c6170a in 2.6.30 dropped the check that a substream must already have been opened with O_APPEND to be able to open it a second time. This would make it possible for a substream to be switched to append mode, which would mean that non-atomic writes would fail unexpectedly. Signed-off-by: Clemens Ladisch Cc: Signed-off-by: Takashi Iwai --- diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 3071e6f5801..091405385e1 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -248,7 +248,8 @@ static int assign_substream(struct snd_rawmidi *rmidi, int subdevice, list_for_each_entry(substream, &s->substreams, list) { if (substream->opened) { if (stream == SNDRV_RAWMIDI_STREAM_INPUT || - !(mode & SNDRV_RAWMIDI_LFLG_APPEND)) + !(mode & SNDRV_RAWMIDI_LFLG_APPEND) || + !substream->append) continue; } if (subdevice < 0 || subdevice == substream->number) {