[PATCH 2/2] ASoC: sdw_utils: Drop senary_sdca_jack codec device reference on exit
From: Yige Jiang
Date: Thu Nov 26 2026 - 00:18:22 EST
asoc_sdw_senary_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_senary_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).
This helper follows asoc_sdw_rt_sdca_jack_exit() and has the same
problem. senary_sdca_jack_add_codec_device_props() adds no software node
when the jack source is not set, so use the check to skip
device_remove_software_node() only, and always drop the reference and
clear the pointer.
Fixes: 77272ecd96d7 ("ASoC: sdw_utils: add Senary SN624x helpers and codec_info")
Signed-off-by: Yige Jiang <yigejiang86@xxxxxxxxx>
---
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_senary_sdca_jack_common.o built before and after, no new warnings.
No hardware or runtime test was performed.
The path needs a Senary SN624x 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_senary_sdca_jack_common.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/sound/soc/sdw_utils/soc_sdw_senary_sdca_jack_common.c b/sound/soc/sdw_utils/soc_sdw_senary_sdca_jack_common.c
index 1dab6f99877d..6954041b7962 100644
--- a/sound/soc/sdw_utils/soc_sdw_senary_sdca_jack_common.c
+++ b/sound/soc/sdw_utils/soc_sdw_senary_sdca_jack_common.c
@@ -150,10 +150,9 @@ int asoc_sdw_senary_sdca_jack_exit(struct snd_soc_card *card, struct snd_soc_dai
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