From: Takashi Iwai <tiwai@suse.de>
To: Cen Zhang <zzzccc427@gmail.com>
Cc: Takashi Iwai <tiwai@suse.de>,
perex@perex.cz, tiwai@suse.com, phucduc.bui@gmail.com,
kees@kernel.org, blum@kernel.org, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org, baijiaju1990@gmail.com,
jjzuming@gmail.com
Subject: Re: [PATCH] ALSA: jack: Remove debugfs before freeing unregistered jacks
Date: Tue, 13 Oct 2026 08:57:01 +0200 [thread overview]
Message-ID: <87h5iqozpe.wl-tiwai@suse.de> (raw)
In-Reply-To: <CAFRLqsW7Y8YZok60ezLw9WKDXQMWd1=3NDQ5fxAoa+dotFRAUA@mail.gmail.com>
On Tue, 13 Oct 2026 06:21:22 +0200,
Cen Zhang wrote:
>
> Hi Takashi,
>
> Takashi Iwai <tiwai@suse.de> 于2026年10月12日周一 15:28写道:
> >
> > Could you verify whether the problem still exists with the latest
> > sound.git tree for-next branch (i.e. for 7.4)? There have been fixes
> > for the races at the disconnection, and snd_card_disconnect() became
> > already mandatory before the release.
> >
>
> Thank you for the review and pointing out the recent disconnection
> fixes. I checked
> sound.git for-next at 8d70e364e866. A potential remaining issue is in
> the cleanup after a failed HDA codec rebind on a live card. The call
> paths below show how a newly created, unregistered jack can be freed
> before its debugfs entries are removed.
>
> For the generic HDA codec driver, jack creation follows:
>
> hda_codec_driver_probe()
> snd_hda_codec_build_controls()
> snd_hda_gen_build_controls() [build_controls callback]
> snd_hda_jack_add_kctls()
> add_jack_kctl()
> snd_hda_jack_add_kctl_mst()
> snd_jack_new()
>
> snd_jack_new() creates a component in SNDRV_DEV_BUILD. With
> CONFIG_SND_JACK_INJECTION_DEBUG enabled, snd_jack_kctl_add() publishes
> its debugfs files. Even though the card already exists, this newly
> created component is not registered yet.
>
> If a later jack-control allocation fails, the error returns to
> hda_codec_driver_probe() before its snd_card_register() call. Its error
> path reaches:
>
> snd_hda_codec_cleanup_for_unbind()
> snd_hda_jack_tbl_clear()
> snd_device_free()
> __snd_device_free()
> __snd_device_disconnect() [skips SNDRV_DEV_BUILD]
> snd_jack_dev_free()
>
> snd_jack_dev_free() unlinks the controls and frees their snd_jack_kctl
> attachments before calling snd_jack_dev_disconnect(). By then the
> kctl_list is empty, so snd_jack_remove_debugfs() has no entries left to
> remove. The card-level debugfs directory has not been removed by a
> snd_card_disconnect() call along this cleanup path.
Thanks, now it's clearer.
IMO, ideally speaking, the debugfs entry addition should be done at
the registration phase, i.e. snd_jack_debugfs_add_inject_node() should
be performed in snd_jack_dev_register(). But it'd be a larger change,
so I take your patch as a quick fix for now to for-next branch.
thanks,
Takashi
prev parent reply other threads:[~2026-10-13 6:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 15:55 [PATCH] ALSA: jack: Remove debugfs before freeing unregistered jacks Cen Zhang
2026-10-12 7:28 ` Takashi Iwai
2026-10-13 4:21 ` Cen Zhang
2026-10-13 6:57 ` Takashi Iwai [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h5iqozpe.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=baijiaju1990@gmail.com \
--cc=blum@kernel.org \
--cc=jjzuming@gmail.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=phucduc.bui@gmail.com \
--cc=tiwai@suse.com \
--cc=zzzccc427@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.