Re: 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: 徐晗翔
Date: Wed Nov 25 2026 - 07:43:37 EST
That patch does work, thanks.
> -----原始邮件-----
> 发件人: "Sreeraj S Kurup" <sreekuttan2156239@xxxxxxxxx>
> 发送时间:2026-11-24 17:39:42 (星期二)
> 收件人: xuhx@xxxxxxxxxxx
> 抄送: broonie@xxxxxxxxxx, lgirdwood@xxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-sound@xxxxxxxxxxxxxxx, perex@xxxxxxxx, tiwai@xxxxxxxx
> 主题: 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)
>
> 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