From: Kery Qi <qikeyu2017@gmail.com>
To: peter.ujfalusi@gmail.com
Cc: linux-kernel@vger.kernel.org, Kery Qi <qikeyu2017@gmail.com>
Subject: [PATCH] ASoC: omap-twl4030: Add missing of_node_put() in omap_twl4030_probe
Date: Wed, 7 Jan 2026 22:49:26 +0800 [thread overview]
Message-ID: <20260107144925.1466-2-qikeyu2017@gmail.com> (raw)
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
reply other threads:[~2026-01-07 14:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260107144925.1466-2-qikeyu2017@gmail.com \
--to=qikeyu2017@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.ujfalusi@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 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®