Re: [PATCH v4 09/33] ALSA: usb-audio: Release interface claims when probe fails
From: Takashi Iwai
Date: Wed Dec 02 2026 - 11:42:33 EST
On Tue, 24 Nov 2026 10:43:40 +0100,
Leon Romanovsky wrote:
>
> From: Leon Romanovsky <leonro@xxxxxxxxxx>
>
> If the first control-interface probe fails after claiming streaming or
> MIDI interfaces, freeing the card leaves those claims behind. Module
> unload can then race with registration of the claimed interfaces and
> leave dangling driver pointers.
>
> Release auxiliary claims when discarding a newly created card. Preserve
> them when a failed secondary probe leaves an existing card in use.
>
> Fixes: 9ad3d6ccf5ee ("[PATCH] USB: Remove USB private semaphore")
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
Reviewed-by: Takashi Iwai <tiwai@xxxxxxx>
thanks,
Takashi
> ---
> sound/usb/card.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/sound/usb/card.c b/sound/usb/card.c
> index 59979b793fe91..56ebdd61f72e7 100644
> --- a/sound/usb/card.c
> +++ b/sound/usb/card.c
> @@ -1090,6 +1090,13 @@ static int usb_audio_probe(struct usb_interface *intf,
> atomic_dec(&chip->active);
> if (!chip->num_interfaces) {
> usb_audio_disconnect_components(chip);
> + for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) {
> + struct usb_interface *iface = dev->actconfig->interface[i];
> +
> + if (iface->dev.driver == &usb_audio_driver.driver &&
> + usb_get_intfdata(iface) == USB_AUDIO_IFACE_UNUSED)
> + usb_driver_release_interface(&usb_audio_driver, iface);
> + }
> snd_card_free(chip->card);
> }
> }
>
> --
> 2.56.1
>