提交 0635eb9f 编写于 作者: M Miaoqian Lin 提交者: Zheng Zengkai

ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe

stable inclusion
from stable-v5.10.121
commit e84aaf23ca82753d765bf84d05295d9d9c5fed29
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6CQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=e84aaf23ca82753d765bf84d05295d9d9c5fed29

--------------------------------

[ Upstream commit 41cd312d ]

of_find_i2c_device_by_node() takes a reference,
In error paths, we should call put_device() to drop
the reference to aviod refount leak.

Fixes: 81e8e492 ("ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000")
Signed-off-by: NMiaoqian Lin <linmq006@gmail.com>
Reviewed-by: NFabio Estevam <festevam@gmail.com>
Link: https://lore.kernel.org/r/20220511065803.3957-1-linmq006@gmail.comSigned-off-by: NMark Brown <broonie@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 3a09b813
...@@ -120,19 +120,19 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) ...@@ -120,19 +120,19 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data) { if (!data) {
ret = -ENOMEM; ret = -ENOMEM;
goto fail; goto put_device;
} }
comp = devm_kzalloc(&pdev->dev, 3 * sizeof(*comp), GFP_KERNEL); comp = devm_kzalloc(&pdev->dev, 3 * sizeof(*comp), GFP_KERNEL);
if (!comp) { if (!comp) {
ret = -ENOMEM; ret = -ENOMEM;
goto fail; goto put_device;
} }
data->codec_clk = clk_get(&codec_dev->dev, NULL); data->codec_clk = clk_get(&codec_dev->dev, NULL);
if (IS_ERR(data->codec_clk)) { if (IS_ERR(data->codec_clk)) {
ret = PTR_ERR(data->codec_clk); ret = PTR_ERR(data->codec_clk);
goto fail; goto put_device;
} }
data->clk_frequency = clk_get_rate(data->codec_clk); data->clk_frequency = clk_get_rate(data->codec_clk);
...@@ -158,10 +158,10 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) ...@@ -158,10 +158,10 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
data->card.dev = &pdev->dev; data->card.dev = &pdev->dev;
ret = snd_soc_of_parse_card_name(&data->card, "model"); ret = snd_soc_of_parse_card_name(&data->card, "model");
if (ret) if (ret)
goto fail; goto put_device;
ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing"); ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing");
if (ret) if (ret)
goto fail; goto put_device;
data->card.num_links = 1; data->card.num_links = 1;
data->card.owner = THIS_MODULE; data->card.owner = THIS_MODULE;
data->card.dai_link = &data->dai; data->card.dai_link = &data->dai;
...@@ -176,7 +176,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) ...@@ -176,7 +176,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
if (ret != -EPROBE_DEFER) if (ret != -EPROBE_DEFER)
dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
ret); ret);
goto fail; goto put_device;
} }
of_node_put(ssi_np); of_node_put(ssi_np);
...@@ -184,6 +184,8 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) ...@@ -184,6 +184,8 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
return 0; return 0;
put_device:
put_device(&codec_dev->dev);
fail: fail:
if (data && !IS_ERR(data->codec_clk)) if (data && !IS_ERR(data->codec_clk))
clk_put(data->codec_clk); clk_put(data->codec_clk);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册