]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ASoC: mediatek: mt8173-rt5650-rt5514: fix refcount leak in mt8173_rt5650_rt5514_dev_p...
authorWang Yufen <wangyufen@huawei.com>
Mon, 5 Dec 2022 10:04:24 +0000 (18:04 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:39 +0000 (11:41 +0100)
[ Upstream commit f08b5bab3487fe33a1bc3052747139da677c6a7f ]

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: 4df22356d3f2 ("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>
sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c

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