Linux-ARM-MSM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] ASoC: qcom: common: Fix NULL pointer in of parser
@ 2019-06-18  5:28 Bjorn Andersson
  2019-06-18  8:12 ` Srinivas Kandagatla
  2019-06-19 12:12 ` Applied "ASoC: qcom: common: Fix NULL pointer in of parser" to the asoc tree Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Bjorn Andersson @ 2019-06-18  5:28 UTC (permalink / raw)
  To: Patrick Lai, Banajit Goswami, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai
  Cc: alsa-devel, linux-kernel, linux-arm-msm, Srinivas Kandagatla

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: 1e36ea360ab9 ("ASoC: qcom: common: use modern dai_link style")
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 sound/soc/qcom/common.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
index c7a878507220..97488b5cc515 100644
--- a/sound/soc/qcom/common.c
+++ b/sound/soc/qcom/common.c
@@ -42,17 +42,17 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
 	card->num_links = num_links;
 	link = card->dai_link;
 
-	dlc = devm_kzalloc(dev, 2 * sizeof(*dlc), GFP_KERNEL);
-	if (!dlc)
-		return -ENOMEM;
+	for_each_child_of_node(dev->of_node, np) {
+		dlc = devm_kzalloc(dev, 2 * sizeof(*dlc), GFP_KERNEL);
+		if (!dlc)
+			return -ENOMEM;
 
-	link->cpus	= &dlc[0];
-	link->platforms	= &dlc[1];
+		link->cpus	= &dlc[0];
+		link->platforms	= &dlc[1];
 
-	link->num_cpus		= 1;
-	link->num_platforms	= 1;
+		link->num_cpus		= 1;
+		link->num_platforms	= 1;
 
-	for_each_child_of_node(dev->of_node, np) {
 		cpu = of_get_child_by_name(np, "cpu");
 		platform = of_get_child_by_name(np, "platform");
 		codec = of_get_child_by_name(np, "codec");
-- 
2.18.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: qcom: common: Fix NULL pointer in of parser
  2019-06-18  5:28 [PATCH] ASoC: qcom: common: Fix NULL pointer in of parser Bjorn Andersson
@ 2019-06-18  8:12 ` Srinivas Kandagatla
  2019-06-19 12:12 ` Applied "ASoC: qcom: common: Fix NULL pointer in of parser" to the asoc tree Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2019-06-18  8:12 UTC (permalink / raw)
  To: Bjorn Andersson, Patrick Lai, Banajit Goswami, Liam Girdwood,
	Mark Brown, Jaroslav Kysela, Takashi Iwai
  Cc: alsa-devel, linux-kernel, linux-arm-msm

Thanks Bjorn for this patch.

On 18/06/2019 06:28, Bjorn Andersson wrote:
> 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: 1e36ea360ab9 ("ASoC: qcom: common: use modern dai_link style")
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

I think the original patch did not realize that there are multiple links!

Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Applied "ASoC: qcom: common: Fix NULL pointer in of parser" to the asoc tree
  2019-06-18  5:28 [PATCH] ASoC: qcom: common: Fix NULL pointer in of parser Bjorn Andersson
  2019-06-18  8:12 ` Srinivas Kandagatla
@ 2019-06-19 12:12 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2019-06-19 12:12 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: alsa-devel, Banajit Goswami, Jaroslav Kysela, Liam Girdwood,
	linux-arm-msm, linux-kernel, Mark Brown, Patrick Lai,
	Srinivas Kandagatla, Takashi Iwai

The patch

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

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.3

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 16395ceee11f8f8af764bac76adc20a43ba1a153 Mon Sep 17 00:00:00 2001
From: Bjorn Andersson <bjorn.andersson@linaro.org>
Date: Mon, 17 Jun 2019 22:28:13 -0700
Subject: [PATCH] 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: 1e36ea360ab9 ("ASoC: qcom: common: use modern dai_link style")
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/qcom/common.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
index c7a878507220..97488b5cc515 100644
--- a/sound/soc/qcom/common.c
+++ b/sound/soc/qcom/common.c
@@ -42,17 +42,17 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
 	card->num_links = num_links;
 	link = card->dai_link;
 
-	dlc = devm_kzalloc(dev, 2 * sizeof(*dlc), GFP_KERNEL);
-	if (!dlc)
-		return -ENOMEM;
+	for_each_child_of_node(dev->of_node, np) {
+		dlc = devm_kzalloc(dev, 2 * sizeof(*dlc), GFP_KERNEL);
+		if (!dlc)
+			return -ENOMEM;
 
-	link->cpus	= &dlc[0];
-	link->platforms	= &dlc[1];
+		link->cpus	= &dlc[0];
+		link->platforms	= &dlc[1];
 
-	link->num_cpus		= 1;
-	link->num_platforms	= 1;
+		link->num_cpus		= 1;
+		link->num_platforms	= 1;
 
-	for_each_child_of_node(dev->of_node, np) {
 		cpu = of_get_child_by_name(np, "cpu");
 		platform = of_get_child_by_name(np, "platform");
 		codec = of_get_child_by_name(np, "codec");
-- 
2.20.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-18  5:28 [PATCH] ASoC: qcom: common: Fix NULL pointer in of parser Bjorn Andersson
2019-06-18  8:12 ` Srinivas Kandagatla
2019-06-19 12:12 ` Applied "ASoC: qcom: common: Fix NULL pointer in of parser" to the asoc tree Mark Brown

Linux-ARM-MSM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-msm/0 linux-arm-msm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-msm linux-arm-msm/ https://lore.kernel.org/linux-arm-msm \
		linux-arm-msm@vger.kernel.org linux-arm-msm@archiver.kernel.org
	public-inbox-index linux-arm-msm


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-arm-msm


AGPL code for this site: git clone https://public-inbox.org/ public-inbox