Commit 16395cee authored by Bjorn Andersson's avatar Bjorn Andersson Committed by Mark Brown

ASoC: qcom: common: Fix NULL pointer in of parser

A snd_soc_dai_link_component is allocated and associated with the first
link, so when the code tries to assign the of_node of the second link's
"cpu" member it dereferences a NULL pointer.

Fix this by moving the allocation and assignement of
snd_soc_dai_link_components into the loop, giving us one pair per link.

Fixes: 1e36ea36 ("ASoC: qcom: common: use modern dai_link style")
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Acked-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent e711223a
...@@ -42,6 +42,7 @@ int qcom_snd_parse_of(struct snd_soc_card *card) ...@@ -42,6 +42,7 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
card->num_links = num_links; card->num_links = num_links;
link = card->dai_link; link = card->dai_link;
for_each_child_of_node(dev->of_node, np) {
dlc = devm_kzalloc(dev, 2 * sizeof(*dlc), GFP_KERNEL); dlc = devm_kzalloc(dev, 2 * sizeof(*dlc), GFP_KERNEL);
if (!dlc) if (!dlc)
return -ENOMEM; return -ENOMEM;
...@@ -52,7 +53,6 @@ int qcom_snd_parse_of(struct snd_soc_card *card) ...@@ -52,7 +53,6 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
link->num_cpus = 1; link->num_cpus = 1;
link->num_platforms = 1; link->num_platforms = 1;
for_each_child_of_node(dev->of_node, np) {
cpu = of_get_child_by_name(np, "cpu"); cpu = of_get_child_by_name(np, "cpu");
platform = of_get_child_by_name(np, "platform"); platform = of_get_child_by_name(np, "platform");
codec = of_get_child_by_name(np, "codec"); codec = of_get_child_by_name(np, "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