ALSA: hda: Fix potential race in unsol event handler
authorTakashi Iwai <tiwai@suse.de>
Sat, 16 May 2020 06:25:56 +0000 (08:25 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Oct 2020 11:12:44 +0000 (13:12 +0200)
commitbbbe8afb08ffc5483aba995583b079bb287fd2de
treeaf23b058884cb50fd51f7cac977df476872e463e
parent3d01f225c61c2127ba4f79713cb696e71620f21d
ALSA: hda: Fix potential race in unsol event handler

[ Upstream commit c637fa151259c0f74665fde7cba5b7eac1417ae5 ]

The unsol event handling code has a loop retrieving the read/write
indices and the arrays without locking while the append to the array
may happen concurrently.  This may lead to some inconsistency.
Although there hasn't been any proof of this bad results, it's still
safer to protect the racy accesses.

This patch adds the spinlock protection around the unsol handling loop
for addressing it.  Here we take bus->reg_lock as the writer side
snd_hdac_bus_queue_event() is also protected by that lock.

Link: https://lore.kernel.org/r/20200516062556.30951-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/hda/hdac_bus.c