Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sound: oss: midibuf: fix sleep_on races

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 <arnd@arndb.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Arnd Bergmann and committed by
Takashi Iwai
76439c2a 7bd6972a

+9 -9
+9 -9
sound/oss/midibuf.c
··· 86 86 */ 87 87 88 88 if (midi_devs[dev]->buffer_status != NULL) 89 - while (!signal_pending(current) && midi_devs[dev]->buffer_status(dev)) 90 - interruptible_sleep_on_timeout(&midi_sleeper[dev], 91 - HZ/10); 89 + wait_event_interruptible_timeout(midi_sleeper[dev], 90 + !midi_devs[dev]->buffer_status(dev), HZ/10); 92 91 } 93 92 94 93 static void midi_input_intr(int dev, unsigned char data) ··· 232 233 * devices 233 234 */ 234 235 235 - while (!signal_pending(current) && DATA_AVAIL(midi_out_buf[dev])) 236 - interruptible_sleep_on(&midi_sleeper[dev]); 236 + wait_event_interruptible(midi_sleeper[dev], 237 + !DATA_AVAIL(midi_out_buf[dev])); 237 238 /* 238 239 * Sync 239 240 */ ··· 281 282 goto out; 282 283 } 283 284 284 - interruptible_sleep_on(&midi_sleeper[dev]); 285 - if (signal_pending(current)) 285 + if (wait_event_interruptible(midi_sleeper[dev], 286 + SPACE_AVAIL(midi_out_buf[dev]))) 286 287 { 287 288 c = -EINTR; 288 289 goto out; ··· 324 325 c = -EAGAIN; 325 326 goto out; 326 327 } 327 - interruptible_sleep_on_timeout(&input_sleeper[dev], 328 - parms[dev].prech_timeout); 328 + wait_event_interruptible_timeout(input_sleeper[dev], 329 + DATA_AVAIL(midi_in_buf[dev]), 330 + parms[dev].prech_timeout); 329 331 330 332 if (signal_pending(current)) 331 333 c = -EINTR; /* The user is getting restless */