From: Sushanto <seditorofficial@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>
Cc: Chen-Yu Tsai <wens@csie.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
alsa-devel@alsa-project.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org,
Sushanto <seditorofficial@gmail.com>
Subject: [PATCH] ASoC: sun4i-codec: Fix OF node reference leaks for analog controls
Date: Tue, 25 Aug 2026 20:10:35 +0600 [thread overview]
Message-ID: <20260825141035.784-1-seditorofficial@gmail.com> (raw)
The device node obtained from of_parse_phandle() for
"allwinner,codec-analog-controls" in sun8i_a23_codec_create_card(),
sun8i_h3_codec_create_card(), and sun8i_v3s_codec_create_card()
has its reference count incremented by of_parse_phandle().
However, the driver fails to drop this reference count when
sun4i_codec_create_link() fails, when snd_soc_register_card() fails
in sun4i_codec_probe(), or when the driver is removed in
sun4i_codec_remove().
Fix this by adding the missing of_node_put(aux_dev.dlc.of_node) calls
in these error paths and in sun4i_codec_remove().
Fixes: 08289086b0ab ("ASoC: sun4i-codec: Add support for A23 codec")
Signed-off-by: Sushanto <seditorofficial@gmail.com>
---
sound/soc/sunxi/sun4i-codec.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index 835dc3404..b10c2beac 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -1429,8 +1429,11 @@ static struct snd_soc_card *sun8i_a23_codec_create_card(struct device *dev)
}
card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
- if (!card->dai_link)
+ if (!card->dai_link) {
+ of_node_put(aux_dev.dlc.of_node);
+ aux_dev.dlc.of_node = NULL;
return ERR_PTR(-ENOMEM);
+ }
card->dev = dev;
card->owner = THIS_MODULE;
@@ -1468,8 +1471,11 @@ static struct snd_soc_card *sun8i_h3_codec_create_card(struct device *dev)
}
card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
- if (!card->dai_link)
+ if (!card->dai_link) {
+ of_node_put(aux_dev.dlc.of_node);
+ aux_dev.dlc.of_node = NULL;
return ERR_PTR(-ENOMEM);
+ }
card->dev = dev;
card->owner = THIS_MODULE;
@@ -1507,8 +1513,11 @@ static struct snd_soc_card *sun8i_v3s_codec_create_card(struct device *dev)
}
card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
- if (!card->dai_link)
+ if (!card->dai_link) {
+ of_node_put(aux_dev.dlc.of_node);
+ aux_dev.dlc.of_node = NULL;
return ERR_PTR(-ENOMEM);
+ }
card->dev = dev;
card->owner = THIS_MODULE;
@@ -1808,6 +1817,8 @@ static int sun4i_codec_probe(struct platform_device *pdev)
ret = snd_soc_register_card(card);
if (ret) {
dev_err_probe(&pdev->dev, ret, "Failed to register our card\n");
+ of_node_put(aux_dev.dlc.of_node);
+ aux_dev.dlc.of_node = NULL;
goto err_assert_reset;
}
@@ -1830,6 +1841,8 @@ static int sun4i_codec_remove(struct platform_device *pdev)
if (scodec->rst)
reset_control_assert(scodec->rst);
clk_disable_unprepare(scodec->clk_apb);
+ of_node_put(aux_dev.dlc.of_node);
+ aux_dev.dlc.of_node = NULL;
return 0;
}
--
2.55.0.windows.4
reply other threads:[~2026-08-25 14:10 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=20260825141035.784-1-seditorofficial@gmail.com \
--to=seditorofficial@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=jernej.skrabec@gmail.com \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=samuel@sholland.org \
--cc=wens@csie.org \
/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