Commit e45ac783 authored by Miaoqian Lin's avatar Miaoqian Lin Committed by Mark Brown

ASoC: mediatek: mt8192-mt6359: Fix error handling in mt8192_mt6359_dev_probe

The device_node pointer is returned by of_parse_phandle()  with refcount
incremented. We should use of_node_put() on it when done.

This function only calls of_node_put() in the regular path.
And it will cause refcount leak in error paths.
Fix this by calling of_node_put() in error handling too.

Fixes: 4e28491a ("ASoC: mediatek: mt8192-mt6359: fix device_node leak")
Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
Reviewed-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20220308015224.23585-1-linmq006@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 5575f7f4
...@@ -1116,8 +1116,10 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev) ...@@ -1116,8 +1116,10 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
} }
card = (struct snd_soc_card *)of_device_get_match_data(&pdev->dev); card = (struct snd_soc_card *)of_device_get_match_data(&pdev->dev);
if (!card) if (!card) {
return -EINVAL; ret = -EINVAL;
goto put_platform_node;
}
card->dev = &pdev->dev; card->dev = &pdev->dev;
hdmi_codec = of_parse_phandle(pdev->dev.of_node, hdmi_codec = of_parse_phandle(pdev->dev.of_node,
...@@ -1159,20 +1161,24 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev) ...@@ -1159,20 +1161,24 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
} }
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv) {
return -ENOMEM; ret = -ENOMEM;
goto put_hdmi_codec;
}
snd_soc_card_set_drvdata(card, priv); snd_soc_card_set_drvdata(card, priv);
ret = mt8192_afe_gpio_init(&pdev->dev); ret = mt8192_afe_gpio_init(&pdev->dev);
if (ret) { if (ret) {
dev_err(&pdev->dev, "init gpio error %d\n", ret); dev_err(&pdev->dev, "init gpio error %d\n", ret);
return ret; goto put_hdmi_codec;
} }
ret = devm_snd_soc_register_card(&pdev->dev, card); ret = devm_snd_soc_register_card(&pdev->dev, card);
of_node_put(platform_node); put_hdmi_codec:
of_node_put(hdmi_codec); of_node_put(hdmi_codec);
put_platform_node:
of_node_put(platform_node);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment