linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: Intel: mrfld: fix uninitialized variable access
@ 2018-11-03 21:21 Arnd Bergmann
  2018-11-04 15:10 ` [alsa-devel] " Pierre-Louis Bossart
  2018-11-05 11:58 ` Applied "ASoC: Intel: mrfld: fix uninitialized variable access" to the asoc tree Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2018-11-03 21:21 UTC (permalink / raw)
  To: Pierre-Louis Bossart, Liam Girdwood, Jie Yang, Mark Brown
  Cc: Arnd Bergmann, Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel

Randconfig testing revealed a very old bug, with gcc-8:

sound/soc/intel/atom/sst/sst_loader.c: In function 'sst_load_fw':
sound/soc/intel/atom/sst/sst_loader.c:357:5: error: 'fw' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  if (fw == NULL) {
     ^
sound/soc/intel/atom/sst/sst_loader.c:354:25: note: 'fw' was declared here
  const struct firmware *fw;

We must check the return code of request_firmware() before we look at the
pointer result that may be uninitialized when the function fails.

Fixes: 9012c9544eea ("ASoC: Intel: mrfld - Add DSP load and management")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 sound/soc/intel/atom/sst/sst_loader.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/intel/atom/sst/sst_loader.c b/sound/soc/intel/atom/sst/sst_loader.c
index 27413ebae956..b8c456753f01 100644
--- a/sound/soc/intel/atom/sst/sst_loader.c
+++ b/sound/soc/intel/atom/sst/sst_loader.c
@@ -354,14 +354,14 @@ static int sst_request_fw(struct intel_sst_drv *sst)
 	const struct firmware *fw;
 
 	retval = request_firmware(&fw, sst->firmware_name, sst->dev);
-	if (fw == NULL) {
-		dev_err(sst->dev, "fw is returning as null\n");
-		return -EINVAL;
-	}
 	if (retval) {
 		dev_err(sst->dev, "request fw failed %d\n", retval);
 		return retval;
 	}
+	if (fw == NULL) {
+		dev_err(sst->dev, "fw is returning as null\n");
+		return -EINVAL;
+	}
 	mutex_lock(&sst->sst_lock);
 	retval = sst_cache_and_parse_fw(sst, fw);
 	mutex_unlock(&sst->sst_lock);
-- 
2.18.0


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

* Re: [alsa-devel] [PATCH] ASoC: Intel: mrfld: fix uninitialized variable access
  2018-11-03 21:21 [PATCH] ASoC: Intel: mrfld: fix uninitialized variable access Arnd Bergmann
@ 2018-11-04 15:10 ` Pierre-Louis Bossart
  2018-11-05 11:58 ` Applied "ASoC: Intel: mrfld: fix uninitialized variable access" to the asoc tree Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Pierre-Louis Bossart @ 2018-11-04 15:10 UTC (permalink / raw)
  To: Arnd Bergmann, Liam Girdwood, Jie Yang, Mark Brown
  Cc: Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel


On 11/3/18 4:21 PM, Arnd Bergmann wrote:
> Randconfig testing revealed a very old bug, with gcc-8:
>
> sound/soc/intel/atom/sst/sst_loader.c: In function 'sst_load_fw':
> sound/soc/intel/atom/sst/sst_loader.c:357:5: error: 'fw' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>    if (fw == NULL) {
>       ^
> sound/soc/intel/atom/sst/sst_loader.c:354:25: note: 'fw' was declared here
>    const struct firmware *fw;
>
> We must check the return code of request_firmware() before we look at the
> pointer result that may be uninitialized when the function fails.

yes indeed, good catch.

Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

>
> Fixes: 9012c9544eea ("ASoC: Intel: mrfld - Add DSP load and management")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   sound/soc/intel/atom/sst/sst_loader.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/sound/soc/intel/atom/sst/sst_loader.c b/sound/soc/intel/atom/sst/sst_loader.c
> index 27413ebae956..b8c456753f01 100644
> --- a/sound/soc/intel/atom/sst/sst_loader.c
> +++ b/sound/soc/intel/atom/sst/sst_loader.c
> @@ -354,14 +354,14 @@ static int sst_request_fw(struct intel_sst_drv *sst)
>   	const struct firmware *fw;
>   
>   	retval = request_firmware(&fw, sst->firmware_name, sst->dev);
> -	if (fw == NULL) {
> -		dev_err(sst->dev, "fw is returning as null\n");
> -		return -EINVAL;
> -	}
>   	if (retval) {
>   		dev_err(sst->dev, "request fw failed %d\n", retval);
>   		return retval;
>   	}
> +	if (fw == NULL) {
> +		dev_err(sst->dev, "fw is returning as null\n");
> +		return -EINVAL;
> +	}
>   	mutex_lock(&sst->sst_lock);
>   	retval = sst_cache_and_parse_fw(sst, fw);
>   	mutex_unlock(&sst->sst_lock);

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

* Applied "ASoC: Intel: mrfld: fix uninitialized variable access" to the asoc tree
  2018-11-03 21:21 [PATCH] ASoC: Intel: mrfld: fix uninitialized variable access Arnd Bergmann
  2018-11-04 15:10 ` [alsa-devel] " Pierre-Louis Bossart
@ 2018-11-05 11:58 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2018-11-05 11:58 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Pierre-Louis Bossart, Mark Brown, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, Mark Brown, linux-kernel, alsa-devel,
	Takashi Iwai, alsa-devel

The patch

   ASoC: Intel: mrfld: fix uninitialized variable access

has been applied to the asoc tree at

   https://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

From 1539c7f23f256120f89f8b9ec53160790bce9ed2 Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <arnd@arndb.de>
Date: Sat, 3 Nov 2018 22:21:22 +0100
Subject: [PATCH] ASoC: Intel: mrfld: fix uninitialized variable access

Randconfig testing revealed a very old bug, with gcc-8:

sound/soc/intel/atom/sst/sst_loader.c: In function 'sst_load_fw':
sound/soc/intel/atom/sst/sst_loader.c:357:5: error: 'fw' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  if (fw == NULL) {
     ^
sound/soc/intel/atom/sst/sst_loader.c:354:25: note: 'fw' was declared here
  const struct firmware *fw;

We must check the return code of request_firmware() before we look at the
pointer result that may be uninitialized when the function fails.

Fixes: 9012c9544eea ("ASoC: Intel: mrfld - Add DSP load and management")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/atom/sst/sst_loader.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/intel/atom/sst/sst_loader.c b/sound/soc/intel/atom/sst/sst_loader.c
index 27413ebae956..b8c456753f01 100644
--- a/sound/soc/intel/atom/sst/sst_loader.c
+++ b/sound/soc/intel/atom/sst/sst_loader.c
@@ -354,14 +354,14 @@ static int sst_request_fw(struct intel_sst_drv *sst)
 	const struct firmware *fw;
 
 	retval = request_firmware(&fw, sst->firmware_name, sst->dev);
-	if (fw == NULL) {
-		dev_err(sst->dev, "fw is returning as null\n");
-		return -EINVAL;
-	}
 	if (retval) {
 		dev_err(sst->dev, "request fw failed %d\n", retval);
 		return retval;
 	}
+	if (fw == NULL) {
+		dev_err(sst->dev, "fw is returning as null\n");
+		return -EINVAL;
+	}
 	mutex_lock(&sst->sst_lock);
 	retval = sst_cache_and_parse_fw(sst, fw);
 	mutex_unlock(&sst->sst_lock);
-- 
2.19.0.rc2


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

end of thread, other threads:[~2018-11-05 11:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-03 21:21 [PATCH] ASoC: Intel: mrfld: fix uninitialized variable access Arnd Bergmann
2018-11-04 15:10 ` [alsa-devel] " Pierre-Louis Bossart
2018-11-05 11:58 ` Applied "ASoC: Intel: mrfld: fix uninitialized variable access" to the asoc tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).