mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
ALSA: firewire-motu: Protect register DSP event queue positions
[ Upstream commit98fb1c1bb1] The register DSP event queue is updated under parser->lock, but snd_motu_register_dsp_message_parser_count_event() reads pull_pos and push_pos without the lock. snd_motu_register_dsp_message_parser_copy_event() also reads both queue positions before taking the lock. Protect these accesses with parser->lock as well. This keeps the hwdep poll/read path consistent with the producer side and with the cached meter/parameter accessors. Fixes:634ec0b290("ALSA: firewire-motu: notify event for parameter change in register DSP model") Cc: stable@vger.kernel.org Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com> Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20260521-alsa-firewire-motu-event-locking-v1-1-708e1c2b5e56@gmail.com [ converted copy_event() from manual spin_lock_irqsave/spin_unlock_irqrestore to guard(spinlock_irqsave) ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
b3f4f82d13
commit
1cdb07d894
@@ -393,6 +393,8 @@ unsigned int snd_motu_register_dsp_message_parser_count_event(struct snd_motu *m
|
||||
{
|
||||
struct msg_parser *parser = motu->message_parser;
|
||||
|
||||
guard(spinlock_irqsave)(&parser->lock);
|
||||
|
||||
if (parser->pull_pos > parser->push_pos)
|
||||
return EVENT_QUEUE_SIZE - parser->pull_pos + parser->push_pos;
|
||||
else
|
||||
@@ -402,14 +404,14 @@ unsigned int snd_motu_register_dsp_message_parser_count_event(struct snd_motu *m
|
||||
bool snd_motu_register_dsp_message_parser_copy_event(struct snd_motu *motu, u32 *event)
|
||||
{
|
||||
struct msg_parser *parser = motu->message_parser;
|
||||
unsigned int pos = parser->pull_pos;
|
||||
unsigned long flags;
|
||||
unsigned int pos;
|
||||
|
||||
if (pos == parser->push_pos)
|
||||
guard(spinlock_irqsave)(&parser->lock);
|
||||
|
||||
if (parser->pull_pos == parser->push_pos)
|
||||
return false;
|
||||
|
||||
spin_lock_irqsave(&parser->lock, flags);
|
||||
|
||||
pos = parser->pull_pos;
|
||||
*event = parser->event_queue[pos];
|
||||
|
||||
++pos;
|
||||
@@ -417,7 +419,5 @@ bool snd_motu_register_dsp_message_parser_copy_event(struct snd_motu *motu, u32
|
||||
pos = 0;
|
||||
parser->pull_pos = pos;
|
||||
|
||||
spin_unlock_irqrestore(&parser->lock, flags);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user