Skip to content

Commit

Permalink
ASoC: mediatek: mt8173-rt5650: Fix refcount leak in mt8173_rt5650_dev…
Browse files Browse the repository at this point in the history
…_probe

[ Upstream commit efe2178 ]

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: 0f83f92 ("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>
  • Loading branch information
Yuuoniy authored and Sasha Levin committed Aug 24, 2022
1 parent d8d7745 commit 9df1475
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sound/soc/mediatek/mt8173/mt8173-rt5650.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
if (!mt8173_rt5650_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_codecs[1].of_node = mt8173_rt5650_codecs[0].of_node;

Expand All @@ -272,7 +273,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_codecs[1].dai_name = codec_capture_dai;
}
Expand All @@ -293,7 +294,8 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
if (!mt8173_rt5650_dais[DAI_LINK_HDMI_I2S].codec_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;

Expand All @@ -302,6 +304,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;
}
Expand Down

0 comments on commit 9df1475

Please sign in to comment.