Skip to content

Commit 2759caa

Browse files
committed
ALSA: seq: oss: Avoid mutex lock for a long-time ioctl
Recently we applied a fix to cover the whole OSS sequencer ioctls with the mutex for dealing with the possible races. This works fine in general, but in theory, this may lead to unexpectedly long stall if an ioctl like SNDCTL_SEQ_SYNC is issued and an event with the far future timestamp was queued. For fixing such a potential stall, this patch changes the mutex lock applied conditionally excluding such an ioctl command. Also, change the mutex_lock() with the interruptible version for user to allow escaping from the big-hammer mutex. Fixes: 80982c7 ("ALSA: seq: oss: Serialize ioctls") Suggested-by: Pavel Machek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent cdc01a1 commit 2759caa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sound/core/seq/oss/seq_oss.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,12 @@ odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
174174
if (snd_BUG_ON(!dp))
175175
return -ENXIO;
176176

177-
mutex_lock(&register_mutex);
177+
if (cmd != SNDCTL_SEQ_SYNC &&
178+
mutex_lock_interruptible(&register_mutex))
179+
return -ERESTARTSYS;
178180
rc = snd_seq_oss_ioctl(dp, cmd, arg);
179-
mutex_unlock(&register_mutex);
181+
if (cmd != SNDCTL_SEQ_SYNC)
182+
mutex_unlock(&register_mutex);
180183
return rc;
181184
}
182185

0 commit comments

Comments
 (0)