]> www.infradead.org Git - users/hch/misc.git/commitdiff
ALSA: seq: Fix KCSAN data-race warning at snd_seq_fifo_poll_wait()
authorTakashi Iwai <tiwai@suse.de>
Wed, 17 Sep 2025 12:13:27 +0000 (14:13 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 17 Sep 2025 12:14:12 +0000 (14:14 +0200)
snd_seq_fifo_poll_wait() evaluates f->cells without locking after
poll_wait(), and KCSAN doesn't like it as it appears to be a
data-race.  Although this doesn't matter much in practice as the value
is volatile, it's still better to address it for the mind piece.

Wrap it with f->lock spinlock for avoiding the potential data race.

Reported-by: syzbot+c3dbc239259940ededba@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=c3dbc239259940ededba
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/seq/seq_fifo.c

index f23c6b7ae2403ccfd18acedd305624c780394df6..91cce18901114bbca163331aa13715d63ff4bc5c 100644 (file)
@@ -210,6 +210,7 @@ int snd_seq_fifo_poll_wait(struct snd_seq_fifo *f, struct file *file,
                           poll_table *wait)
 {
        poll_wait(file, &f->input_sleep, wait);
+       guard(spinlock_irq)(&f->lock);
        return (f->cells > 0);
 }