Skip to contentSkip to conversation

ASoC: Intel: Skylake: Fix uninitialized pointer usage

PATCH In review Vinod Koul 3 participants 8 messages Apr 27, 2017 – Apr 30, 2017

Subsystems (3)
lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

PATCH 1/3 ASoC: Intel: Skylake: Fix uninitialized pointer usage

Due to recent code move, one instance dev_err() was passed a wrong uninitialized pointer for the device, so fix it.

sound/soc/intel/skylake/bxt-sst.c: In function 'bxt_sst_dsp_init':
sound/soc/intel/skylake/bxt-sst.c:567:14: warning: 'skl' may be used uninitialized in this function [-Wmaybe-uninitialized]

   dev_err(skl->dev, "%s: no device\n", __func__);
              ^
Fixes 9fe9c7119283 ("ASoC: Intel: Skylake: Move sst common initialization to a helper function")
---
 sound/soc/intel/skylake/bxt-sst.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/skylake/bxt-sst.c +1 -1
index fde4bc0f35b0..f5e7dbb1ba39 100644
@@ -564,7 +564,7 @@ int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
 
 	ret = skl_sst_ctx_init(dev, irq, fw_name, dsp_ops, dsp, &skl_dev);
 	if (ret < 0) {
-		dev_err(skl->dev, "%s: no device\n", __func__);
+		dev_err(dev, "%s: no device\n", __func__);
 		return ret;
 	}
 
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 2/3 ASoC: Intel: Skylake: Fix unused variable warning

With compiler option W=1, we have one more warning in the driver for 'set but unused variable', so remove the unused variable to fix it.

sound/soc/intel/skylake/skl-pcm.c: In function ‘skl_platform_open’:
sound/soc/intel/skylake/skl-pcm.c:954:26: warning: variable ‘runtime’ set but not used [-Wunused-but-set-variable]
struct snd_pcm_runtime *runtime;

---
 sound/soc/intel/skylake/skl-pcm.c | 2 --
 1 file changed, 2 deletions(-)
sound/soc/intel/skylake/skl-pcm.c +0 -2
index d43d1976dd3b..e91bbcffc856 100644
@@ -951,14 +951,12 @@ static int skl_link_hw_free(struct snd_pcm_substream *substream,
 
 static int skl_platform_open(struct snd_pcm_substream *substream)
 {
-	struct snd_pcm_runtime *runtime;
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai_link *dai_link = rtd->dai_link;
 
 	dev_dbg(rtd->cpu_dai->dev, "In %s:%s\n", __func__,
 					dai_link->cpu_dai_name);
 
-	runtime = substream->runtime;
 	snd_soc_set_runtime_hwparams(substream, &azx_pcm_hw);
 
 	return 0;
Signature · 6 lines
1.9.1

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
maintainer
#2 lore raw

Applied "ASoC: Intel: Skylake: Fix unused variable warning" to the asoc tree

The patch

ASoC: Intel: Skylake: Fix unused variable warning

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

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

Quoted 1 line

From 9ed4aefe6f5f7e1dfe6abe8b15cfc8c48963b6c0 Mon Sep 17 00:00:00 2001

From: Vinod Koul <[email protected]>
Date: Thu, 27 Apr 2017 12:21:21 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Fix unused variable warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

With compiler option W=1, we have one more warning in the driver for 'set but unused variable', so remove the unused variable to fix it.

sound/soc/intel/skylake/skl-pcm.c: In function ‘skl_platform_open’:
sound/soc/intel/skylake/skl-pcm.c:954:26: warning: variable ‘runtime’ set but not used [-Wunused-but-set-variable]
struct snd_pcm_runtime *runtime;

---
 sound/soc/intel/skylake/skl-pcm.c | 2 --
 1 file changed, 2 deletions(-)
sound/soc/intel/skylake/skl-pcm.c +0 -2
index d43d1976dd3b..e91bbcffc856 100644
@@ -951,14 +951,12 @@ static struct snd_soc_dai_driver skl_platform_dai[] = {
 
 static int skl_platform_open(struct snd_pcm_substream *substream)
 {
-	struct snd_pcm_runtime *runtime;
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai_link *dai_link = rtd->dai_link;
 
 	dev_dbg(rtd->cpu_dai->dev, "In %s:%s\n", __func__,
 					dai_link->cpu_dai_name);
 
-	runtime = substream->runtime;
 	snd_soc_set_runtime_hwparams(substream, &azx_pcm_hw);
 
 	return 0;
Signature · 1 line
2.11.0
author
#3 lore raw

PATCH 3/3 ASoC: Intel: Skylake: Return negative error code

In reply to Vinod Koul

From: Guneshwor Singh <[email protected]>

skl_tplg_add_pipe() returned EEXIST instead of negative EEXIST, so fix that and handle the return value as well.

---
 sound/soc/intel/skylake/skl-topology.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
sound/soc/intel/skylake/skl-topology.c +7 -5
index 0e459d3eb17a..29f68713a231 100644
@@ -1711,7 +1711,7 @@ static int skl_tplg_add_pipe(struct device *dev,
 	list_for_each_entry(ppl, &skl->ppl_list, node) {
 		if (ppl->pipe->ppl_id == tkn_elem->value) {
 			mconfig->pipe = ppl->pipe;
-			return EEXIST;
+			return -EEXIST;
 		}
 	}
 
@@ -2003,11 +2003,13 @@ static int skl_tplg_get_token(struct device *dev,
 		ret = skl_tplg_add_pipe(dev,
 				mconfig, skl, tkn_elem);
 
-		if (ret < 0)
+		if (ret < 0) {
+			if (ret == -EEXIST) {
+				is_pipe_exists = 1;
+				break;
+			}
 			return is_pipe_exists;
-
-		if (ret == EEXIST)
-			is_pipe_exists = 1;
+		}
 
 		break;
 
Signature · 1 line
1.9.1
maintainer
#4 lore raw

Applied "ASoC: Intel: Skylake: Return negative error code" to the asoc tree

The patch

ASoC: Intel: Skylake: Return negative error code

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

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

Quoted 1 line

From 081dc8ab46df85382658822e951ea79be87382b0 Mon Sep 17 00:00:00 2001

From: Guneshwor Singh <[email protected]>
Date: Thu, 27 Apr 2017 12:21:22 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Return negative error code

skl_tplg_add_pipe() returned EEXIST instead of negative EEXIST, so fix that and handle the return value as well.

---
 sound/soc/intel/skylake/skl-topology.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
sound/soc/intel/skylake/skl-topology.c +7 -5
index 0e459d3eb17a..29f68713a231 100644
@@ -1711,7 +1711,7 @@ static int skl_tplg_add_pipe(struct device *dev,
 	list_for_each_entry(ppl, &skl->ppl_list, node) {
 		if (ppl->pipe->ppl_id == tkn_elem->value) {
 			mconfig->pipe = ppl->pipe;
-			return EEXIST;
+			return -EEXIST;
 		}
 	}
 
@@ -2003,11 +2003,13 @@ static int skl_tplg_get_token(struct device *dev,
 		ret = skl_tplg_add_pipe(dev,
 				mconfig, skl, tkn_elem);
 
-		if (ret < 0)
+		if (ret < 0) {
+			if (ret == -EEXIST) {
+				is_pipe_exists = 1;
+				break;
+			}
 			return is_pipe_exists;
-
-		if (ret == EEXIST)
-			is_pipe_exists = 1;
+		}
 
 		break;
 
Signature · 1 line
2.11.0
Reviewed-by on v1 1/3
#5 lore raw
In reply to Vinod Koul
Quoted 8 lines · Vinod Koul

Due to recent code move, one instance dev_err() was passed a wrong uninitialized pointer for the device, so fix it.

sound/soc/intel/skylake/bxt-sst.c: In function 'bxt_sst_dsp_init':
sound/soc/intel/skylake/bxt-sst.c:567:14: warning: 'skl' may be used uninitialized in this function [-Wmaybe-uninitialized]

   dev_err(skl->dev, "%s: no device\n", __func__);
              ^
Quoted 6 lines
Fixes 9fe9c7119283 ("ASoC: Intel: Skylake: Move sst common initialization to a helper function")
---
 sound/soc/intel/skylake/bxt-sst.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Dan and Colin were also going to fix this apparent bug. It's nice to add their contribution, I think.

http://mailman.alsa-project.org/pipermail/alsa-devel/2017-April/120225.html
http://mailman.alsa-project.org/pipermail/alsa-devel/2017-April/120242.html

sound/soc/intel/skylake/bxt-sst.c int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, · line 569

Quoted 12 lines
sound/soc/intel/skylake/bxt-sst.c +1 -1
index fde4bc0f35b0..f5e7dbb1ba39 100644
@@ -564,7 +564,7 @@ int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
 
 	ret = skl_sst_ctx_init(dev, irq, fw_name, dsp_ops, dsp, &skl_dev);
 	if (ret < 0) {
-		dev_err(skl->dev, "%s: no device\n", __func__);
+		dev_err(dev, "%s: no device\n", __func__);
 		return ret;
 	}

Regards

Takashi Sakamoto

author
#6 lore raw
Quoted 16 lines · Takashi Sakamoto
Quoted 8 lines · Vinod Koul

Due to recent code move, one instance dev_err() was passed a wrong uninitialized pointer for the device, so fix it.

sound/soc/intel/skylake/bxt-sst.c: In function 'bxt_sst_dsp_init':
sound/soc/intel/skylake/bxt-sst.c:567:14: warning: 'skl' may be used uninitialized in this function [-Wmaybe-uninitialized]

   dev_err(skl->dev, "%s: no device\n", __func__);
              ^
Quoted 6 lines
Fixes 9fe9c7119283 ("ASoC: Intel: Skylake: Move sst common initialization to a helper function")
---
 sound/soc/intel/skylake/bxt-sst.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 7 lines

Dan and Colin were also going to fix this apparent bug. It's nice to add their contribution, I think.

you missed Arnd :)

So based on this rule we should also add:

Quoted 21 lines

http://mailman.alsa-project.org/pipermail/alsa-devel/2017-April/120225.html
http://mailman.alsa-project.org/pipermail/alsa-devel/2017-April/120242.html

sound/soc/intel/skylake/bxt-sst.c int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, · line 569

Quoted 12 lines
sound/soc/intel/skylake/bxt-sst.c +1 -1
index fde4bc0f35b0..f5e7dbb1ba39 100644
@@ -564,7 +564,7 @@ int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
 
 	ret = skl_sst_ctx_init(dev, irq, fw_name, dsp_ops, dsp, &skl_dev);
 	if (ret < 0) {
-		dev_err(skl->dev, "%s: no device\n", __func__);
+		dev_err(dev, "%s: no device\n", __func__);
 		return ret;
 	}

Regards

Takashi Sakamoto

Signature · 1 line
~Vinod
maintainer
#7 lore raw

Applied "ASoC: Intel: Skylake: fix uninitialized pointer use" to the asoc tree

In reply to Vinod Koul

The patch

ASoC: Intel: Skylake: fix uninitialized pointer use

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

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

Quoted 1 line

From 351d74e4d7eacaab2ed0092b855355d5e2907117 Mon Sep 17 00:00:00 2001

From: Arnd Bergmann <[email protected]>
Date: Thu, 27 Apr 2017 12:59:58 +0200
Subject: [PATCH] ASoC: Intel: Skylake: fix uninitialized pointer use

The error handling in bxt_sst_dsp_init() got changed in a way that it now derefences an uninitialized pointer when printing a warning about the device not being found:

sound/soc/intel/skylake/bxt-sst.c: In function 'bxt_sst_dsp_init':
sound/soc/intel/skylake/bxt-sst.c:567:14: error: 'skl' may be used uninitialized in this function [-Werror=maybe-uninitialized]

As we do have a valid device pointer available at the call site, let's use that instead.

Fixes 9fe9c7119283 ("ASoC: Intel: Skylake: Move sst common initialization to a helper function")
---
 sound/soc/intel/skylake/bxt-sst.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/skylake/bxt-sst.c +1 -1
index fde4bc0f35b0..f5e7dbb1ba39 100644
@@ -564,7 +564,7 @@ int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
 
 	ret = skl_sst_ctx_init(dev, irq, fw_name, dsp_ops, dsp, &skl_dev);
 	if (ret < 0) {
-		dev_err(skl->dev, "%s: no device\n", __func__);
+		dev_err(dev, "%s: no device\n", __func__);
 		return ret;
 	}
 
Signature · 1 line
2.11.0