Skip to contentSkip to conversation

ASoC: mediatek: mt8195: add missing of_node_put in probe

PATCH In review Trevor Wu 2 participants 2 messages Sep 28, 2021

Subsystems (3)
lore
Share & tools
lore

Trevor Wu

author
#0 lore raw

PATCH 1/1 ASoC: mediatek: mt8195: add missing of_node_put in probe

dp node and hdmi node are retrieved from of_parse_phandle(), so using of_node_put() on them before return.

---
 .../mt8195/mt8195-mt6359-rt1019-rt5682.c      | 25 +++++++++++--------
 1 file changed, 15 insertions(+), 10 deletions(-)
sound/soc/mediatek/mt8195/mt8195-mt6359-rt1019-rt5682.c +15 -10
index a3fa8efc8f81..cb15467e5fc5 100644
@@ -995,6 +995,8 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev)
 {
 	struct snd_soc_card *card = &mt8195_mt6359_rt1019_rt5682_soc_card;
 	struct device_node *platform_node;
+	struct device_node *dp_node;
+	struct device_node *hdmi_node;
 	struct snd_soc_dai_link *dai_link;
 	struct mt8195_mt6359_rt1019_rt5682_priv *priv = NULL;
 	int ret, i;
@@ -1013,12 +1015,12 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev)
 			dai_link->platforms->of_node = platform_node;
 
 		if (strcmp(dai_link->name, "DPTX_BE") == 0) {
-			dai_link->codecs->of_node =
-				of_parse_phandle(pdev->dev.of_node,
-						 "mediatek,dptx-codec", 0);
-			if (!dai_link->codecs->of_node) {
+			dp_node = of_parse_phandle(pdev->dev.of_node,
+						   "mediatek,dptx-codec", 0);
+			if (!dp_node) {
 				dev_dbg(&pdev->dev, "No property 'dptx-codec'\n");
 			} else {
+				dai_link->codecs->of_node = dp_node;
 				dai_link->codecs->name = NULL;
 				dai_link->codecs->dai_name = "i2s-hifi";
 				dai_link->init = mt8195_dptx_codec_init;
@@ -1026,12 +1028,12 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev)
 		}
 
 		if (strcmp(dai_link->name, "ETDM3_OUT_BE") == 0) {
-			dai_link->codecs->of_node =
-				of_parse_phandle(pdev->dev.of_node,
-						 "mediatek,hdmi-codec", 0);
-			if (!dai_link->codecs->of_node) {
+			hdmi_node = of_parse_phandle(pdev->dev.of_node,
+						     "mediatek,hdmi-codec", 0);
+			if (!hdmi_node) {
 				dev_dbg(&pdev->dev, "No property 'hdmi-codec'\n");
 			} else {
+				dai_link->codecs->of_node = hdmi_node;
 				dai_link->codecs->name = NULL;
 				dai_link->codecs->dai_name = "i2s-hifi";
 				dai_link->init = mt8195_hdmi_codec_init;
@@ -1041,8 +1043,8 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev)
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv) {
-		of_node_put(platform_node);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto out;
 	}
 
 	snd_soc_card_set_drvdata(card, priv);
@@ -1052,6 +1054,9 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n",
 			__func__, ret);
 
+out:
+	of_node_put(hdmi_node);
+	of_node_put(dp_node);
 	of_node_put(platform_node);
 	return ret;
 }
Signature · 1 line
2.18.0
maintainer
#1 lore raw
Quoted 4 lines · Trevor Wu

dp node and hdmi node are retrieved from of_parse_phandle(), so using of_node_put() on them before return.

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: mediatek: mt8195: add missing of_node_put in probe

      commit: b05cfb1215223a750cff5367b625f0ed285a36cf

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark