Skip to content

Commit 38eef3b

Browse files
wangyufen316broonie
authored andcommitted
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: 11c0269 ("ASoC: Mediatek: MT8183: Add machine driver with TS3A227") Signed-off-by: Wang Yufen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent a39bc7c commit 38eef3b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,10 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev)
677677
}
678678

679679
card = (struct snd_soc_card *)of_device_get_match_data(&pdev->dev);
680-
if (!card)
680+
if (!card) {
681+
of_node_put(platform_node);
681682
return -EINVAL;
683+
}
682684
card->dev = &pdev->dev;
683685

684686
ec_codec = of_parse_phandle(pdev->dev.of_node, "mediatek,ec-codec", 0);
@@ -767,16 +769,19 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev)
767769
}
768770

769771
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
770-
if (!priv)
771-
return -ENOMEM;
772+
if (!priv) {
773+
ret = -ENOMEM;
774+
goto out;
775+
}
772776

773777
snd_soc_card_set_drvdata(card, priv);
774778

775779
priv->pinctrl = devm_pinctrl_get(&pdev->dev);
776780
if (IS_ERR(priv->pinctrl)) {
777781
dev_err(&pdev->dev, "%s devm_pinctrl_get failed\n",
778782
__func__);
779-
return PTR_ERR(priv->pinctrl);
783+
ret = PTR_ERR(priv->pinctrl);
784+
goto out;
780785
}
781786

782787
for (i = 0; i < PIN_STATE_MAX; i++) {
@@ -809,6 +814,7 @@ mt8183_mt6358_ts3a227_max98357_dev_probe(struct platform_device *pdev)
809814

810815
ret = devm_snd_soc_register_card(&pdev->dev, card);
811816

817+
out:
812818
of_node_put(platform_node);
813819
of_node_put(ec_codec);
814820
of_node_put(hdmi_codec);

0 commit comments

Comments
 (0)