Re: [PATCH 5.15 564/779] ASoC: mediatek: mt8173: Fix refcount leak in mt8173_rt5650_rt5676_dev_probe
From: Pavel Machek
Date: Fri Aug 19 2022 - 09:17:07 EST
Hi!
> From: Miaoqian Lin <linmq006@xxxxxxxxx>
>
> [ Upstream commit ae4f11c1ed2d67192fdf3d89db719ee439827c11 ]
>
> of_parse_phandle() returns a node pointer with refcount
> incremented, we should use of_node_put() on it when not need anymore.
> Fix missing of_node_put() in error paths.
Is this correct?
> +++ b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c
> @@ -256,14 +256,16 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)
> if (!mt8173_rt5650_rt5676_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_node;
> }
...
> dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n",
> __func__, ret);
>
> +put_node:
> of_node_put(platform_node);
> return ret;
> }
In success case, platform_node is stored:
dai_link->platforms->of_node = platform_node;
I guess we should not be doing put in that case.
Best regards,
Pavel
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Attachment:
signature.asc
Description: PGP signature