summaryrefslogtreecommitdiff
path: root/sound/soc
diff options
context:
space:
mode:
authorMiaoqian Lin <linmq006@gmail.com>2022-03-08 01:52:22 +0000
committerMark Brown <broonie@kernel.org>2022-03-08 12:27:59 +0000
commite45ac7831ff3e2934d58cce319c17c8ec763c95c (patch)
treeea5dc9973fcfe00bcfb49f0ffa08c7aae34c6cbf /sound/soc
parent5575f7f49134c7386a684335c9007737c606d3b5 (diff)
ASoC: mediatek: mt8192-mt6359: Fix error handling in mt8192_mt6359_dev_probe
The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done. This function only calls of_node_put() in the regular path. And it will cause refcount leak in error paths. Fix this by calling of_node_put() in error handling too. Fixes: 4e28491a7a19 ("ASoC: mediatek: mt8192-mt6359: fix device_node leak") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20220308015224.23585-1-linmq006@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
index f7daad1bfe1e..ee91569c0911 100644
--- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
+++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
@@ -1116,8 +1116,10 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
}
card = (struct snd_soc_card *)of_device_get_match_data(&pdev->dev);
- if (!card)
- return -EINVAL;
+ if (!card) {
+ ret = -EINVAL;
+ goto put_platform_node;
+ }
card->dev = &pdev->dev;
hdmi_codec = of_parse_phandle(pdev->dev.of_node,
@@ -1159,20 +1161,24 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
}
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
- if (!priv)
- return -ENOMEM;
+ if (!priv) {
+ ret = -ENOMEM;
+ goto put_hdmi_codec;
+ }
snd_soc_card_set_drvdata(card, priv);
ret = mt8192_afe_gpio_init(&pdev->dev);
if (ret) {
dev_err(&pdev->dev, "init gpio error %d\n", ret);
- return ret;
+ goto put_hdmi_codec;
}
ret = devm_snd_soc_register_card(&pdev->dev, card);
- of_node_put(platform_node);
+put_hdmi_codec:
of_node_put(hdmi_codec);
+put_platform_node:
+ of_node_put(platform_node);
return ret;
}