Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: mediatek: mt8195: add missing of_node_put in probe

dp node and hdmi node are retrieved from of_parse_phandle(), so using
of_node_put() on them before return.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Link: https://lore.kernel.org/r/20210928063520.23927-1-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Trevor Wu and committed by
Mark Brown
b05cfb12 3e5cdded

+15 -10
+15 -10
sound/soc/mediatek/mt8195/mt8195-mt6359-rt1019-rt5682.c
··· 996 996 { 997 997 struct snd_soc_card *card = &mt8195_mt6359_rt1019_rt5682_soc_card; 998 998 struct device_node *platform_node; 999 + struct device_node *dp_node; 1000 + struct device_node *hdmi_node; 999 1001 struct snd_soc_dai_link *dai_link; 1000 1002 struct mt8195_mt6359_rt1019_rt5682_priv *priv = NULL; 1001 1003 int ret, i; ··· 1016 1014 dai_link->platforms->of_node = platform_node; 1017 1015 1018 1016 if (strcmp(dai_link->name, "DPTX_BE") == 0) { 1019 - dai_link->codecs->of_node = 1020 - of_parse_phandle(pdev->dev.of_node, 1021 - "mediatek,dptx-codec", 0); 1022 - if (!dai_link->codecs->of_node) { 1017 + dp_node = of_parse_phandle(pdev->dev.of_node, 1018 + "mediatek,dptx-codec", 0); 1019 + if (!dp_node) { 1023 1020 dev_dbg(&pdev->dev, "No property 'dptx-codec'\n"); 1024 1021 } else { 1022 + dai_link->codecs->of_node = dp_node; 1025 1023 dai_link->codecs->name = NULL; 1026 1024 dai_link->codecs->dai_name = "i2s-hifi"; 1027 1025 dai_link->init = mt8195_dptx_codec_init; ··· 1029 1027 } 1030 1028 1031 1029 if (strcmp(dai_link->name, "ETDM3_OUT_BE") == 0) { 1032 - dai_link->codecs->of_node = 1033 - of_parse_phandle(pdev->dev.of_node, 1034 - "mediatek,hdmi-codec", 0); 1035 - if (!dai_link->codecs->of_node) { 1030 + hdmi_node = of_parse_phandle(pdev->dev.of_node, 1031 + "mediatek,hdmi-codec", 0); 1032 + if (!hdmi_node) { 1036 1033 dev_dbg(&pdev->dev, "No property 'hdmi-codec'\n"); 1037 1034 } else { 1035 + dai_link->codecs->of_node = hdmi_node; 1038 1036 dai_link->codecs->name = NULL; 1039 1037 dai_link->codecs->dai_name = "i2s-hifi"; 1040 1038 dai_link->init = mt8195_hdmi_codec_init; ··· 1044 1042 1045 1043 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 1046 1044 if (!priv) { 1047 - of_node_put(platform_node); 1048 - return -ENOMEM; 1045 + ret = -ENOMEM; 1046 + goto out; 1049 1047 } 1050 1048 1051 1049 snd_soc_card_set_drvdata(card, priv); ··· 1055 1053 dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n", 1056 1054 __func__, ret); 1057 1055 1056 + out: 1057 + of_node_put(hdmi_node); 1058 + of_node_put(dp_node); 1058 1059 of_node_put(platform_node); 1059 1060 return ret; 1060 1061 }