Skip to content

Commit

Permalink
sound: oss: midibuf: fix sleep_on races
Browse files Browse the repository at this point in the history
sleep_on is known to be racy and going away because of this. All instances
of interruptible_sleep_on and interruptible_sleep_on_timeout in the midibuf
driver can trivially be replaced with wait_event_interruptible and
wait_event_interruptible_timeout.

[fixed coding style warnings by tiwai]

Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
arndb authored and tiwai committed Jan 14, 2014
1 parent 7bd6972 commit 76439c2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions sound/oss/midibuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ static void drain_midi_queue(int dev)
*/

if (midi_devs[dev]->buffer_status != NULL)
while (!signal_pending(current) && midi_devs[dev]->buffer_status(dev))
interruptible_sleep_on_timeout(&midi_sleeper[dev],
HZ/10);
wait_event_interruptible_timeout(midi_sleeper[dev],
!midi_devs[dev]->buffer_status(dev), HZ/10);
}

static void midi_input_intr(int dev, unsigned char data)
Expand Down Expand Up @@ -233,8 +232,8 @@ void MIDIbuf_release(int dev, struct file *file)
* devices
*/

while (!signal_pending(current) && DATA_AVAIL(midi_out_buf[dev]))
interruptible_sleep_on(&midi_sleeper[dev]);
wait_event_interruptible(midi_sleeper[dev],
!DATA_AVAIL(midi_out_buf[dev]));
/*
* Sync
*/
Expand Down Expand Up @@ -282,8 +281,8 @@ int MIDIbuf_write(int dev, struct file *file, const char __user *buf, int count)
goto out;
}

interruptible_sleep_on(&midi_sleeper[dev]);
if (signal_pending(current))
if (wait_event_interruptible(midi_sleeper[dev],
SPACE_AVAIL(midi_out_buf[dev])))
{
c = -EINTR;
goto out;
Expand Down Expand Up @@ -325,8 +324,9 @@ int MIDIbuf_read(int dev, struct file *file, char __user *buf, int count)
c = -EAGAIN;
goto out;
}
interruptible_sleep_on_timeout(&input_sleeper[dev],
parms[dev].prech_timeout);
wait_event_interruptible_timeout(input_sleeper[dev],
DATA_AVAIL(midi_in_buf[dev]),
parms[dev].prech_timeout);

if (signal_pending(current))
c = -EINTR; /* The user is getting restless */
Expand Down

0 comments on commit 76439c2

Please sign in to comment.