Re: [PATCH] ALSA: usb-audio: Release components on probe errors

From: Takashi Iwai

Date: Mon Jun 29 2026 - 06:31:54 EST


On Thu, 18 Jun 2026 19:00:26 +0200,
Cen Zhang wrote:
>
> usb_audio_probe() can create USB-audio component resources before the
> first interface is recorded in chip->num_interfaces. If a later probe
> step fails, the error path drops chip->active and frees the card directly
> when no interfaces have been registered.
>
> Normal disconnect first releases USB-audio components in a fixed order
> before the card is freed. The first-interface probe error path skipped
> that sequence, so partially initialized PCM, endpoint, MIDI, media, or
> mixer resources could be left for the card private_free path without their
> disconnect handling having run.
>
> Move the existing normal-disconnect component release sequence into a
> helper and call it from the zero-interface probe error path before
> snd_card_free(). Keep the normal disconnect ordering unchanged: PCM
> streams, endpoint resources, MIDI 1.0 resources, MIDI 2.0 resources, media
> device cleanup, then mixer resources.
>
> Assisted-by: Codex:gpt-5.5
> Signed-off-by: Cen Zhang <zzzccc427@xxxxxxxxx>

Applied to for-next branch now. Thanks.


Takashi