Commit 9e4b0f77 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Greg Kroah-Hartman

ASoC: Intel: mrfld: fix uninitialized variable access

[ Upstream commit 1539c7f2 ]

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: 9012c954 ("ASoC: Intel: mrfld - Add DSP load and management")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 9d9fcc11
...@@ -354,14 +354,14 @@ static int sst_request_fw(struct intel_sst_drv *sst) ...@@ -354,14 +354,14 @@ static int sst_request_fw(struct intel_sst_drv *sst)
const struct firmware *fw; const struct firmware *fw;
retval = request_firmware(&fw, sst->firmware_name, sst->dev); 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) { if (retval) {
dev_err(sst->dev, "request fw failed %d\n", retval); dev_err(sst->dev, "request fw failed %d\n", retval);
return retval; return retval;
} }
if (fw == NULL) {
dev_err(sst->dev, "fw is returning as null\n");
return -EINVAL;
}
mutex_lock(&sst->sst_lock); mutex_lock(&sst->sst_lock);
retval = sst_cache_and_parse_fw(sst, fw); retval = sst_cache_and_parse_fw(sst, fw);
mutex_unlock(&sst->sst_lock); mutex_unlock(&sst->sst_lock);
......
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