Re: sound: core: jack kcontrol is published before jack_kctl allocation, and the failure path frees it without removing it from card->controls (null-ptr-deref)

From: Sreeraj S Kurup

Date: Tue Nov 24 2026 - 04:40:13 EST


Hi Hanxiang,

Thanks for the detailed report and the KASAN reproducer.

> The same failure-rollback bug has a deterministic companion path:
> snd_jack_new() can fail after snd_ctl_add() has already published the
> kcontrol (for example, when its subsequent kstrdup() of the jack id
> fails), and it also does not undo the publication.

The companion failure path in snd_jack_new() was already fixed by my upstream commit:

commit ebce20196346906cfa33a84a021ce8f9bd91880c
ALSA: jack: Fix jack control cleanup on error paths

https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/commit/?id=ebce20196346906cfa33a84a021ce8f9bd91880c

The patch initializes jack_kctl->list and routes the failure paths in snd_jack_new() through common
cleanup, ensuring that the previously created kcontrol is removed using snd_ctl_remove().

Could you check whether your reproducer still triggers the issue with this commit applied?

Thanks for reporting this.

Regards,
Sreeraj