* [PATCH 1/2] ASoC: sdw_utils: Drop rt_sdca_jack codec device reference on exit
@ 2026-11-26 5:18 Yige Jiang
2026-11-26 8:03 ` reply: " qianghua.wang
0 siblings, 1 reply; 2+ messages in thread
From: Yige Jiang @ 2026-11-26 5:18 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai, bo liu,
qianghua.wang
Cc: Yige Jiang, Bard Liao, Pierre-Louis Bossart, linux-sound,
linux-kernel, stable
asoc_sdw_rt_sdca_jack_init() takes a reference on the SoundWire codec
device with bus_find_device_by_name() and stores it in
ctx->headset_codec_dev, whatever the jack source quirk is. But
asoc_sdw_rt_sdca_jack_exit() returns early when SOC_SDW_JACK_JDSRC() is
zero, so then the reference is never dropped. One reference on the
codec device leaks each time the card fails to register (including
-EPROBE_DEFER) or the machine driver is removed, when the quirk has no
jack source (DMI quirk entries without one, or the quirk module
parameter).
The jack source check in the exit path is only needed because
rt_sdca_jack_add_codec_device_props() adds no software node when the
jack source is not set. Use it to skip device_remove_software_node()
only, and always drop the reference and clear the pointer, as
asoc_sdw_rt711_exit() does.
Fixes: 526a1876fc48 ("ASoC: Intel: sof_sdw_rt_sdca_jack_common: test SOF_JACK_JDSRC in _exit")
Cc: stable@vger.kernel.org
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Based on linux-next next-20261109 (630059a5a632).
Compile-tested: arm64, GCC 14.2.0, W=1, COMPILE_TEST=y, SND_SOC_INTEL_SOUNDWIRE_SOF_MACH=y, SND_SOC_SDW_UTILS=y; soc_sdw_rt_sdca_jack_common.o built before and after, no new warnings.
No hardware or runtime test was performed.
The path needs an rt_sdca jack codec and a quirk with no jack source; it runs on card registration failure (including -EPROBE_DEFER) and on machine driver removal.
sound/soc/sdw_utils/soc_sdw_rt_sdca_jack_common.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/sound/soc/sdw_utils/soc_sdw_rt_sdca_jack_common.c b/sound/soc/sdw_utils/soc_sdw_rt_sdca_jack_common.c
index b4e427d55130..7902d423c8b9 100644
--- a/sound/soc/sdw_utils/soc_sdw_rt_sdca_jack_common.c
+++ b/sound/soc/sdw_utils/soc_sdw_rt_sdca_jack_common.c
@@ -188,10 +188,9 @@ int asoc_sdw_rt_sdca_jack_exit(struct snd_soc_card *card, struct snd_soc_dai_lin
if (!ctx->headset_codec_dev)
return 0;
- if (!SOC_SDW_JACK_JDSRC(ctx->mc_quirk))
- return 0;
+ if (SOC_SDW_JACK_JDSRC(ctx->mc_quirk))
+ device_remove_software_node(ctx->headset_codec_dev);
- device_remove_software_node(ctx->headset_codec_dev);
put_device(ctx->headset_codec_dev);
ctx->headset_codec_dev = NULL;
base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47
^ permalink raw reply [flat|nested] 2+ messages in thread
* reply: [PATCH 1/2] ASoC: sdw_utils: Drop rt_sdca_jack codec device reference on exit
2026-11-26 5:18 [PATCH 1/2] ASoC: sdw_utils: Drop rt_sdca_jack codec device reference on exit Yige Jiang
@ 2026-11-26 8:03 ` qianghua.wang
0 siblings, 0 replies; 2+ messages in thread
From: qianghua.wang @ 2026-11-26 8:03 UTC (permalink / raw)
To: 'Yige Jiang', 'Liam Girdwood',
'Mark Brown', 'Jaroslav Kysela',
'Takashi Iwai', 'bo liu'
Cc: 'Bard Liao', 'Pierre-Louis Bossart',
linux-sound, linux-kernel, stable
Thanks for the catch.
asoc_sdw_rt_sdca_jack_init() always stores the bus_find_device_by_name()
reference in ctx->headset_codec_dev, while
rt_sdca_jack_add_codec_device_props()
adds no software node when SOC_SDW_JACK_JDSRC() is zero. Returning early
from asoc_sdw_rt_sdca_jack_exit() in that case therefore leaks the reference
(and leaves a stale pointer) on card registration failure / EPROBE_DEFER
/driver removal.
Your change matches the intended cleanup: only call
device_remove_software_node() when a jack-source software node was added,
and always put_device() + clear the pointer, as asoc_sdw_rt711_exit() does
for the
device reference. Cc:stable looks appropriate for Fixes: 526a1876fc48.
Reviewed-by: Qianghua Wang <qianghua.wang@senarytech.com>
-----Original Message-----
From: Yige Jiang <yigejiang86@gmail.com>
Sent: 11/26/2026 13:18
To: Liam Girdwood <lgirdwood@gmail.com>; Mark Brown <broonie@kernel.org>;
Jaroslav Kysela <perex@perex.cz>; Takashi Iwai <tiwai@suse.com>; bo liu
<bo.liu@senarytech.com>; qianghua.wang <qianghua.wang@senarytech.com>
Cc: Yige Jiang <yigejiang86@gmail.com>; Bard Liao
<yung-chuan.liao@linux.intel.com>; Pierre-Louis Bossart
<pierre-louis.bossart@linux.dev>; linux-sound@vger.kernel.org;
linux-kernel@vger.kernel.org; stable@vger.kernel.org
Subject: [PATCH 1/2] ASoC: sdw_utils: Drop rt_sdca_jack codec device
reference on exit
asoc_sdw_rt_sdca_jack_init() takes a reference on the SoundWire codec device
with bus_find_device_by_name() and stores it in
ctx->headset_codec_dev, whatever the jack source quirk is. But
asoc_sdw_rt_sdca_jack_exit() returns early when SOC_SDW_JACK_JDSRC() is
zero, so then the reference is never dropped. One reference on the codec
device leaks each time the card fails to register (including
-EPROBE_DEFER) or the machine driver is removed, when the quirk has no jack
source (DMI quirk entries without one, or the quirk module parameter).
The jack source check in the exit path is only needed because
rt_sdca_jack_add_codec_device_props() adds no software node when the jack
source is not set. Use it to skip device_remove_software_node() only, and
always drop the reference and clear the pointer, as
asoc_sdw_rt711_exit() does.
Fixes: 526a1876fc48 ("ASoC: Intel: sof_sdw_rt_sdca_jack_common: test
SOF_JACK_JDSRC in _exit")
Cc: stable@vger.kernel.org
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Based on linux-next next-20261109 (630059a5a632).
Compile-tested: arm64, GCC 14.2.0, W=1, COMPILE_TEST=y,
SND_SOC_INTEL_SOUNDWIRE_SOF_MACH=y, SND_SOC_SDW_UTILS=y;
soc_sdw_rt_sdca_jack_common.o built before and after, no new warnings.
No hardware or runtime test was performed.
The path needs an rt_sdca jack codec and a quirk with no jack source; it
runs on card registration failure (including -EPROBE_DEFER) and on machine
driver removal.
sound/soc/sdw_utils/soc_sdw_rt_sdca_jack_common.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/sound/soc/sdw_utils/soc_sdw_rt_sdca_jack_common.c
b/sound/soc/sdw_utils/soc_sdw_rt_sdca_jack_common.c
index b4e427d55130..7902d423c8b9 100644
--- a/sound/soc/sdw_utils/soc_sdw_rt_sdca_jack_common.c
+++ b/sound/soc/sdw_utils/soc_sdw_rt_sdca_jack_common.c
@@ -188,10 +188,9 @@ int asoc_sdw_rt_sdca_jack_exit(struct snd_soc_card
*card, struct snd_soc_dai_lin
if (!ctx->headset_codec_dev)
return 0;
- if (!SOC_SDW_JACK_JDSRC(ctx->mc_quirk))
- return 0;
+ if (SOC_SDW_JACK_JDSRC(ctx->mc_quirk))
+ device_remove_software_node(ctx->headset_codec_dev);
- device_remove_software_node(ctx->headset_codec_dev);
put_device(ctx->headset_codec_dev);
ctx->headset_codec_dev = NULL;
base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-26 8:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 5:18 [PATCH 1/2] ASoC: sdw_utils: Drop rt_sdca_jack codec device reference on exit Yige Jiang
2026-11-26 8:03 ` reply: " qianghua.wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®