aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAashish Sharma <[email protected]>2023-04-11 06:04:31 +0530
committerMark Brown <[email protected]>2023-04-11 12:40:07 +0100
commitbeed115c2ce78f990222a29abed042582df4e87c (patch)
treee62d1bdb5e5e51e93ec45300edd2297c29d66b5e
parentfaf15233e59052f4d61cad2da6e56daf33124d96 (diff)
ASoC: mediatek: common: Fix refcount leak in parse_dai_link_info
Add missing of_node_put()s before the returns to balance of_node_get()s and of_node_put()s, which may get unbalanced in case the for loop 'for_each_available_child_of_node' returns early. Fixes: 4302187d955f ("ASoC: mediatek: common: add soundcard driver common code") Reported-by: kernel test robot <[email protected]> Reported-by: Julia Lawall <[email protected]> Link: https://lore.kernel.org/r/[email protected]/ Signed-off-by: Aashish Sharma <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Reviewed-by: Trevor Wu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
-rw-r--r--sound/soc/mediatek/common/mtk-soundcard-driver.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sound/soc/mediatek/common/mtk-soundcard-driver.c b/sound/soc/mediatek/common/mtk-soundcard-driver.c
index 7c55c2cb1f21..738093451ccb 100644
--- a/sound/soc/mediatek/common/mtk-soundcard-driver.c
+++ b/sound/soc/mediatek/common/mtk-soundcard-driver.c
@@ -47,20 +47,26 @@ int parse_dai_link_info(struct snd_soc_card *card)
/* Loop over all the dai link sub nodes */
for_each_available_child_of_node(dev->of_node, sub_node) {
if (of_property_read_string(sub_node, "link-name",
- &dai_link_name))
+ &dai_link_name)) {
+ of_node_put(sub_node);
return -EINVAL;
+ }
for_each_card_prelinks(card, i, dai_link) {
if (!strcmp(dai_link_name, dai_link->name))
break;
}
- if (i >= card->num_links)
+ if (i >= card->num_links) {
+ of_node_put(sub_node);
return -EINVAL;
+ }
ret = set_card_codec_info(card, sub_node, dai_link);
- if (ret < 0)
+ if (ret < 0) {
+ of_node_put(sub_node);
return ret;
+ }
}
return 0;