Skip to contentSkip to conversation

ASoC: codecs: wcd93xx: fix OF node leaks on probe failure

PATCH In review Johan Hovold 3 participants 6 messages Dec 1, 2025 – Dec 4, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover ASoC: codecs: wcd93xx: fix OF node leaks on probe failure

The original wcd938x driver has a couple of OF node reference leaks which have been reproduced in the two later added drivers.

Johan

Johan Hovold (3):
ASoC: codecs: wcd937x: fix OF node leaks on probe failure
ASoC: codecs: wcd938x: fix OF node leaks on probe failure
ASoC: codecs: wcd939x: fix OF node leaks on probe failure

 sound/soc/codecs/wcd937x.c | 4 ++--
 sound/soc/codecs/wcd938x.c | 3 +--
 sound/soc/codecs/wcd939x.c | 3 +--
 3 files changed, 4 insertions(+), 6 deletions(-)
Signature · 1 line
2.51.2
#1 lore raw

PATCH 1/3 ASoC: codecs: wcd937x: fix OF node leaks on probe failure

The component match entry release function will drop the references taken while looking up the soundwire OF nodes when the platform device is unbound.

Drop the additional references taken to avoid leaking them on probe failure (e.g. probe deferral) and on driver unbind.

Fixes 9be3ec196da4 ("ASoC: codecs: wcd937x: add wcd937x codec driver")
Cc Prasad Kumpatla <[email protected]>
Cc Mohammad Rafi Shaik <[email protected]>
---
 sound/soc/codecs/wcd937x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/wcd937x.c +2 -2
index 421ec7a2d6bd..339d2f097218 100644
@@ -2843,7 +2843,7 @@ static int wcd937x_add_slave_components(struct wcd937x_priv *wcd937x,
 		dev_err(dev, "Couldn't parse phandle to qcom,rx-device!\n");
 		return -ENODEV;
 	}
-	of_node_get(wcd937x->rxnode);
+
 	component_match_add_release(dev, matchptr, component_release_of,
 				    component_compare_of, wcd937x->rxnode);
 
@@ -2852,7 +2852,7 @@ static int wcd937x_add_slave_components(struct wcd937x_priv *wcd937x,
 		dev_err(dev, "Couldn't parse phandle to qcom,tx-device\n");
 			return -ENODEV;
 	}
-	of_node_get(wcd937x->txnode);
+
 	component_match_add_release(dev, matchptr, component_release_of,
 				    component_compare_of, wcd937x->txnode);
 
Signature · 1 line
2.51.2
#2 lore raw

PATCH 2/3 ASoC: codecs: wcd938x: fix OF node leaks on probe failure

In reply to Johan Hovold

The component match entry release function will drop the references taken while looking up the soundwire OF nodes when the platform device is unbound.

Drop the additional references taken to avoid leaking them on probe failure (e.g. probe deferral) and on driver unbind.

Fixes 8d78602aa87a ("ASoC: codecs: wcd938x: add basic driver")
Cc Srinivas Kandagatla <[email protected]>
---
 sound/soc/codecs/wcd938x.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/codecs/wcd938x.c +1 -2
index e1a4783b984c..8357f9f1ad72 100644
@@ -3465,7 +3465,6 @@ static int wcd938x_add_slave_components(struct wcd938x_priv *wcd938x,
 		return -ENODEV;
 	}
 
-	of_node_get(wcd938x->rxnode);
 	component_match_add_release(dev, matchptr, component_release_of,
 				    component_compare_of, wcd938x->rxnode);
 
@@ -3474,7 +3473,7 @@ static int wcd938x_add_slave_components(struct wcd938x_priv *wcd938x,
 		dev_err(dev, "%s: Tx-device node not defined\n", __func__);
 		return -ENODEV;
 	}
-	of_node_get(wcd938x->txnode);
+
 	component_match_add_release(dev, matchptr, component_release_of,
 				    component_compare_of, wcd938x->txnode);
 	return 0;
Signature · 1 line
2.51.2
#3 lore raw

PATCH 3/3 ASoC: codecs: wcd939x: fix OF node leaks on probe failure

In reply to Johan Hovold

The component match entry release function will drop the references taken while looking up the soundwire OF nodes when the platform device is unbound.

Drop the additional references taken to avoid leaking them on probe failure (e.g. probe deferral) and on driver unbind.

Fixes 10f514bd172a ("ASoC: codecs: Add WCD939x Codec driver")
Cc Neil Armstrong <[email protected]>
---
 sound/soc/codecs/wcd939x.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/codecs/wcd939x.c +1 -2
index e74e6f013131..4f3be55370e2 100644
@@ -3526,7 +3526,6 @@ static int wcd939x_add_slave_components(struct wcd939x_priv *wcd939x,
 		return -ENODEV;
 	}
 
-	of_node_get(wcd939x->rxnode);
 	component_match_add_release(dev, matchptr, component_release_of,
 				    component_compare_of, wcd939x->rxnode);
 
@@ -3535,7 +3534,7 @@ static int wcd939x_add_slave_components(struct wcd939x_priv *wcd939x,
 		dev_err(dev, "%s: Tx-device node not defined\n", __func__);
 		return -ENODEV;
 	}
-	of_node_get(wcd939x->txnode);
+
 	component_match_add_release(dev, matchptr, component_release_of,
 				    component_compare_of, wcd939x->txnode);
 	return 0;
Signature · 1 line
2.51.2
Reviewed-by on the v1 series
#4 lore raw
In reply to Johan Hovold
Quoted 5 lines · Johan Hovold

The original wcd938x driver has a couple of OF node reference leaks which have been reproduced in the two later added drivers.

Johan

Thanks for the patches,

Yes, of_parse_phandle() already gets a node refcount, another refcount is redundant and will leak.

LGTM

--srini>

Quoted 10 lines

Johan Hovold (3):
ASoC: codecs: wcd937x: fix OF node leaks on probe failure
ASoC: codecs: wcd938x: fix OF node leaks on probe failure
ASoC: codecs: wcd939x: fix OF node leaks on probe failure

 sound/soc/codecs/wcd937x.c | 4 ++--
 sound/soc/codecs/wcd938x.c | 3 +--
 sound/soc/codecs/wcd939x.c | 3 +--
 3 files changed, 4 insertions(+), 6 deletions(-)
maintainer
#5 lore raw
In reply to Johan Hovold
Quoted 6 lines · Johan Hovold

The original wcd938x driver has a couple of OF node reference leaks which have been reproduced in the two later added drivers.

Johan

Quoted 6 lines

Johan Hovold (3):
ASoC: codecs: wcd937x: fix OF node leaks on probe failure
ASoC: codecs: wcd938x: fix OF node leaks on probe failure
ASoC: codecs: wcd939x: fix OF node leaks on probe failure

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/3] ASoC: codecs: wcd937x: fix OF node leaks on probe failure

      commit: 22a03ca7c20c4ed3a75047709b0ad15160e29d58
[2/3] ASoC: codecs: wcd938x: fix OF node leaks on probe failure
      commit: 32ae6ebe171aca9ce10f5790523a9865b6c08b02
[3/3] ASoC: codecs: wcd939x: fix OF node leaks on probe failure
      commit: 3ef4d9ede20db39bff34a559b04a1938fb31251e

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark