* [PATCH] ASoC: sun4i-codec: Fix OF node reference leaks for analog controls
@ 2026-08-25 14:10 Sushanto
0 siblings, 0 replies; only message in thread
From: Sushanto @ 2026-08-25 14:10 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown
Cc: Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, alsa-devel,
linux-arm-kernel, linux-sunxi, linux-kernel, Sushanto
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-25 14:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-25 14:10 [PATCH] ASoC: sun4i-codec: Fix OF node reference leaks for analog controls Sushanto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox