Commit 38eef3be authored by Wang Yufen's avatar Wang Yufen Committed by Mark Brown

ASoC: mediatek: mt8183: fix refcount leak in mt8183_mt6358_ts3a227_max98357_dev_probe()

The node returned by of_parse_phandle() with refcount incremented,
of_node_put() needs be called when finish using it. So add it in the
error path in mt8183_mt6358_ts3a227_max98357_dev_probe().

Fixes: 11c02690 ("ASoC: Mediatek: MT8183: Add machine driver with TS3A227")
Signed-off-by: default avatarWang Yufen <wangyufen@huawei.com>
Link: https://lore.kernel.org/r/1670234188-23596-1-git-send-email-wangyufen@huawei.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent a39bc7cf
...@@ -677,8 +677,10 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev) ...@@ -677,8 +677,10 @@ mt8183_mt6358_ts3a227_max98357_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) {
of_node_put(platform_node);
return -EINVAL; return -EINVAL;
}
card->dev = &pdev->dev; card->dev = &pdev->dev;
ec_codec = of_parse_phandle(pdev->dev.of_node, "mediatek,ec-codec", 0); ec_codec = of_parse_phandle(pdev->dev.of_node, "mediatek,ec-codec", 0);
...@@ -767,8 +769,10 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev) ...@@ -767,8 +769,10 @@ mt8183_mt6358_ts3a227_max98357_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 out;
}
snd_soc_card_set_drvdata(card, priv); snd_soc_card_set_drvdata(card, priv);
...@@ -776,7 +780,8 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev) ...@@ -776,7 +780,8 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev)
if (IS_ERR(priv->pinctrl)) { if (IS_ERR(priv->pinctrl)) {
dev_err(&pdev->dev, "%s devm_pinctrl_get failed\n", dev_err(&pdev->dev, "%s devm_pinctrl_get failed\n",
__func__); __func__);
return PTR_ERR(priv->pinctrl); ret = PTR_ERR(priv->pinctrl);
goto out;
} }
for (i = 0; i < PIN_STATE_MAX; i++) { for (i = 0; i < PIN_STATE_MAX; i++) {
...@@ -809,6 +814,7 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev) ...@@ -809,6 +814,7 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev)
ret = devm_snd_soc_register_card(&pdev->dev, card); ret = devm_snd_soc_register_card(&pdev->dev, card);
out:
of_node_put(platform_node); of_node_put(platform_node);
of_node_put(ec_codec); of_node_put(ec_codec);
of_node_put(hdmi_codec); of_node_put(hdmi_codec);
......
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