Re: [PATCH v2] ALSA: control: Synchronize LED mode accesses

From: Takashi Iwai

Date: Sat Nov 07 2026 - 04:10:17 EST


On Fri, 06 Nov 2026 19:39:53 +0100,
Sreeraj S Kurup wrote:
>
> mode_store() updates led->mode while holding
> snd_ctl_led_mutex.
>
> However, snd_ctl_led_set_state() and mode_show() read this
> field without holding the same mutex.
>
> This can cause a data race when userspace changes the mode
> while another path reads it.
>
> Read the mode under snd_ctl_led_mutex in
> snd_ctl_led_set_state() and use the local value after
> releasing the mutex.
>
> Also protect the mode read in mode_show() with the mutex.
>
> Fixes: cb17fe0045aa ("ALSA: control - add sysfs support to the LED trigger module")
> Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@xxxxxxxxx>

As this sort of data race for a single value has no much impact on the
actual behavior, it's more or less just for consistency.
So I applied to for-next branch. Thanks.


Takashi