* [PATCH] ASoC: omap-twl4030: Add missing of_node_put() in omap_twl4030_probe
@ 2026-01-07 14:49 Kery Qi
0 siblings, 0 replies; only message in thread
From: Kery Qi @ 2026-01-07 14:49 UTC (permalink / raw)
To: peter.ujfalusi; +Cc: linux-kernel, Kery Qi
The omap_twl4030_probe() function calls of_parse_phandle() to acquire
device nodes for the "ti,mcbsp" and "ti,mcbsp-voice" properties.
of_parse_phandle() returns a device node with its reference count
incremented.
If snd_soc_of_parse_audio_routing() or devm_snd_soc_register_card()
fails, the function returns an error without releasing the acquired
device node, which leads to a reference leak.
This patch adds the missing of_node_put() in the error handling paths
to properly decrement the reference count. It also resets the of_node
pointers in the dai_links array to NULL to ensure a clean state upon
failure.
Signed-off-by: Kery Qi <qikeyu2017@gmail.com>
---
sound/soc/ti/omap-twl4030.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/sound/soc/ti/omap-twl4030.c b/sound/soc/ti/omap-twl4030.c
index 4d80f8a7a947..74ec05c915c6 100644
--- a/sound/soc/ti/omap-twl4030.c
+++ b/sound/soc/ti/omap-twl4030.c
@@ -285,8 +285,15 @@ static int omap_twl4030_probe(struct platform_device *pdev)
if (prop) {
ret = snd_soc_of_parse_audio_routing(card,
"ti,audio-routing");
- if (ret)
+ if (ret) {
+ omap_twl4030_dai_links[0].cpus->of_node = NULL;
+ omap_twl4030_dai_links[0].platforms->of_node = NULL;
+ omap_twl4030_dai_links[1].cpus->of_node = NULL;
+ omap_twl4030_dai_links[1].platforms->of_node = NULL;
+ if (dai_node)
+ of_node_put(dai_node);
return ret;
+ }
card->fully_routed = 1;
}
@@ -310,6 +317,12 @@ static int omap_twl4030_probe(struct platform_device *pdev)
if (ret) {
dev_err(&pdev->dev, "devm_snd_soc_register_card() failed: %d\n",
ret);
+ omap_twl4030_dai_links[0].cpus->of_node = NULL;
+ omap_twl4030_dai_links[0].platforms->of_node = NULL;
+ omap_twl4030_dai_links[1].cpus->of_node = NULL;
+ omap_twl4030_dai_links[1].platforms->of_node = NULL;
+ if (dai_node)
+ of_node_put(dai_node);
return ret;
}
--
2.34.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-01-07 14:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-07 14:49 [PATCH] ASoC: omap-twl4030: Add missing of_node_put() in omap_twl4030_probe Kery Qi
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®