mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yuwei Chen <2522445001@qq.com>
To: Mark Brown <broonie@kernel.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Garlic Tseng <garlic.tseng@mediatek.com>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, stable@vger.kernel.org
Subject: [PATCH] ASoC: mediatek: mt2701-cs42448: fix device node leak in probe
Date: Mon, 30 Nov 2026 14:30:45 +0800	[thread overview]
Message-ID: <tencent_55867AD52D9B24FAAC80724D9756142A8506@qq.com> (raw)

mt2701_cs42448_machine_probe() takes three of_parse_phandle()
references, for "mediatek,platform", "mediatek,audio-codec" and
"mediatek,audio-codec-bt-mrg", and stores them in the DAI links. Later
failures in routing, GPIO lookup or card registration return with those
references still held, and the success path never drops them either.

Register a devres action for each parsed node. It runs when probe
fails and, on unbind, only after snd_soc_unregister_card().

Fixes: 1f458d53f76c ("ASoC: mediatek: Add mt2701-cs42448 driver and config option.")
Cc: stable@vger.kernel.org
Signed-off-by: Yuwei Chen <2522445001@qq.com>
---
 sound/soc/mediatek/mt2701/mt2701-cs42448.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/sound/soc/mediatek/mt2701/mt2701-cs42448.c b/sound/soc/mediatek/mt2701/mt2701-cs42448.c
index ff7a1bac848c..2490e764107b 100644
--- a/sound/soc/mediatek/mt2701/mt2701-cs42448.c
+++ b/sound/soc/mediatek/mt2701/mt2701-cs42448.c
@@ -313,6 +313,11 @@ static struct snd_soc_card mt2701_cs42448_soc_card = {
 	.num_dapm_widgets = ARRAY_SIZE(mt2701_cs42448_asoc_card_dapm_widgets),
 };
 
+static void mt2701_cs42448_of_node_put(void *np)
+{
+	of_node_put(np);
+}
+
 static int mt2701_cs42448_machine_probe(struct platform_device *pdev)
 {
 	struct snd_soc_card *card = &mt2701_cs42448_soc_card;
@@ -333,6 +338,10 @@ static int mt2701_cs42448_machine_probe(struct platform_device *pdev)
 		dev_err(dev, "Property 'platform' missing or invalid\n");
 		return -EINVAL;
 	}
+	ret = devm_add_action_or_reset(dev, mt2701_cs42448_of_node_put,
+				       platform_node);
+	if (ret)
+		return ret;
 	for_each_card_prelinks(card, i, dai_link) {
 		if (dai_link->platforms->name)
 			continue;
@@ -348,6 +357,10 @@ static int mt2701_cs42448_machine_probe(struct platform_device *pdev)
 			"Property 'audio-codec' missing or invalid\n");
 		return -EINVAL;
 	}
+	ret = devm_add_action_or_reset(dev, mt2701_cs42448_of_node_put,
+				       codec_node);
+	if (ret)
+		return ret;
 	for_each_card_prelinks(card, i, dai_link) {
 		if (dai_link->codecs->name)
 			continue;
@@ -361,6 +374,10 @@ static int mt2701_cs42448_machine_probe(struct platform_device *pdev)
 			"Property 'audio-codec-bt-mrg' missing or invalid\n");
 		return -EINVAL;
 	}
+	ret = devm_add_action_or_reset(dev, mt2701_cs42448_of_node_put,
+				       codec_node_bt_mrg);
+	if (ret)
+		return ret;
 	mt2701_cs42448_dai_links[DAI_LINK_BE_MRG_BT].codecs->of_node
 							= codec_node_bt_mrg;
 
base-commit: 3dbdc13bd4b313b3d94c0f719378a4641a39db46
-- 
2.53.0.windows.2


                 reply	other threads:[~2026-11-30  6:30 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=tencent_55867AD52D9B24FAAC80724D9756142A8506@qq.com \
    --to=2522445001@qq.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=broonie@kernel.org \
    --cc=garlic.tseng@mediatek.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=perex@perex.cz \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.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®