Commit beed115c authored by Aashish Sharma's avatar Aashish Sharma Committed by Mark Brown

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: 4302187d ("ASoC: mediatek: common: add soundcard driver common code")
Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarJulia Lawall <julia.lawall@inria.fr>
Link: https://lore.kernel.org/r/202304090504.2K8L6soj-lkp@intel.com/Signed-off-by: default avatarAashish Sharma <shraash@google.com>
Reviewed-by: default avatarGuenter Roeck <groeck@chromium.org>
Reviewed-by: default avatarTrevor Wu <trevor.wu@mediatek.com>
Link: https://lore.kernel.org/r/20230411003431.4048700-1-shraash@google.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent faf15233
......@@ -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;
......
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