]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ASoC: mediatek: mt8173-rt5650: Fix refcount leak in mt8173_rt5650_dev_probe
authorMiaoqian Lin <linmq006@gmail.com>
Fri, 3 Jun 2022 12:42:41 +0000 (16:42 +0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:18:01 +0000 (11:18 +0200)
[ Upstream commit d68263963515420f78221a7594ba84da446d91c5 ]

of_parse_phandle() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not need anymore.
Fix refcount leak in some error paths.

Fixes: 9c3f6c50c65c ("ASoC: mediatek: Add machine driver for ALC5650 codec")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Link: https://lore.kernel.org/r/20220603124243.31358-1-linmq006@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/mediatek/mt8173/mt8173-rt5650.c

index 21e7d4d3ded5ad3f76bb6c8fdc15d7f2e6950ece..cdfc697ad94e2b4eb4cba2ecdf12ed76c4803a7b 100644 (file)
@@ -266,7 +266,8 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
        if (!mt8173_rt5650_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 put_platform_node;
        }
        mt8173_rt5650_dais[DAI_LINK_CODEC_I2S].codecs[1].of_node =
                mt8173_rt5650_dais[DAI_LINK_CODEC_I2S].codecs[0].of_node;
@@ -279,7 +280,7 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
                        dev_err(&pdev->dev,
                                "%s codec_capture_dai name fail %d\n",
                                __func__, ret);
-                       return ret;
+                       goto put_platform_node;
                }
                mt8173_rt5650_dais[DAI_LINK_CODEC_I2S].codecs[1].dai_name =
                        codec_capture_dai;
@@ -301,7 +302,8 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
        if (!mt8173_rt5650_dais[DAI_LINK_HDMI_I2S].codecs->of_node) {
                dev_err(&pdev->dev,
                        "Property 'audio-codec' missing or invalid\n");
-               return -EINVAL;
+               ret = -EINVAL;
+               goto put_platform_node;
        }
        card->dev = &pdev->dev;
 
@@ -310,6 +312,7 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n",
                        __func__, ret);
 
+put_platform_node:
        of_node_put(platform_node);
        return ret;
 }