Re: [PATCH v2] ALSA: usb-audio: Protect Roland control activation

From: Takashi Iwai

Date: Tue Sep 29 2026 - 10:32:31 EST


On Tue, 29 Sep 2026 16:17:26 +0200,
Runyu Xiao wrote:
>
> The USB MIDI driver changes the Roland MIDI Input Mode control's access
> flags directly from the rawmidi open and close paths. These changes are
> not protected by the ALSA control core and the corresponding notifications
> can race with control access.
>
> Use snd_ctl_activate_id() so that the control core updates the access flags
> and sends the notification under its lock. Release the USB MIDI mutex
> before calling it because the control write path holds controls_rwsem while
> roland_load_put() takes the USB MIDI mutex.
>
> Keep the state transition and alternate-setting change under the USB MIDI
> mutex; rawmidi's open mutex serializes the enclosing open and close paths.
>
> Fixes: 96f61d9ade82 ("sound: usb-audio: allow switching altsetting on Roland USB MIDI devices")
> Cc: stable@xxxxxxxxxxxxxxx
> Assisted-by: LLM
> Signed-off-by: Runyu Xiao <runyu.xiao@xxxxxxxxxx>

Applied to for-next branch. Thanks.


Takashi