ASoC: mediatek: mt8173-rt5650-rt5514: fix refcount leak in mt8173_rt5650_rt5514_dev_probe()

[ Upstream commit 3327d72111 ]

The node returned by of_parse_phandle() with refcount incremented,
of_node_put() needs be called when finish using it. So add it in the
error path in mt8173_rt5650_rt5514_dev_probe().

Fixes: 0d1d7a6642 ("ASoC: mediatek: Refine mt8173 driver and change config option")
Signed-off-by: Wang Yufen <wangyufen@huawei.com>
Link: https://lore.kernel.org/r/1670234664-24246-1-git-send-email-wangyufen@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Wang Yufen 2022-12-05 18:04:24 +08:00 committed by Greg Kroah-Hartman
parent 44d3eac26a
commit 5f6d57871b

View file

@ -209,14 +209,16 @@ static int mt8173_rt5650_rt5514_dev_probe(struct platform_device *pdev)
if (!mt8173_rt5650_rt5514_codecs[0].of_node) { if (!mt8173_rt5650_rt5514_codecs[0].of_node) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Property 'audio-codec' missing or invalid\n"); "Property 'audio-codec' missing or invalid\n");
return -EINVAL; ret = -EINVAL;
goto out;
} }
mt8173_rt5650_rt5514_codecs[1].of_node = mt8173_rt5650_rt5514_codecs[1].of_node =
of_parse_phandle(pdev->dev.of_node, "mediatek,audio-codec", 1); of_parse_phandle(pdev->dev.of_node, "mediatek,audio-codec", 1);
if (!mt8173_rt5650_rt5514_codecs[1].of_node) { if (!mt8173_rt5650_rt5514_codecs[1].of_node) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Property 'audio-codec' missing or invalid\n"); "Property 'audio-codec' missing or invalid\n");
return -EINVAL; ret = -EINVAL;
goto out;
} }
mt8173_rt5650_rt5514_codec_conf[0].of_node = mt8173_rt5650_rt5514_codec_conf[0].of_node =
mt8173_rt5650_rt5514_codecs[1].of_node; mt8173_rt5650_rt5514_codecs[1].of_node;
@ -229,6 +231,7 @@ static int mt8173_rt5650_rt5514_dev_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n", dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n",
__func__, ret); __func__, ret);
out:
of_node_put(platform_node); of_node_put(platform_node);
return ret; return ret;
} }