[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240911115448.277828-1-suhui@nfschina.com>
Date: Wed, 11 Sep 2024 19:54:50 +0800
From: Su Hui <suhui@...china.com>
To: herve.codina@...tlin.com,
lgirdwood@...il.com,
broonie@...nel.org,
perex@...ex.cz,
tiwai@...e.com,
nathan@...nel.org,
ndesaulniers@...gle.com,
morbo@...gle.com,
justinstitt@...gle.com
Cc: Su Hui <suhui@...china.com>,
alsa-devel@...a-project.org,
linux-sound@...r.kernel.org,
linux-kernel@...r.kernel.org,
llvm@...ts.linux.dev,
kernel-janitors@...r.kernel.org
Subject: [PATCH] ASoC: codecs: avoid possible garbage value in peb2466_reg_read()
Clang static checker (scan-build) warning:
sound/soc/codecs/peb2466.c:232:8:
Assigned value is garbage or undefined [core.uninitialized.Assign]
232 | *val = tmp;
| ^ ~~~
When peb2466_read_byte() fails, 'tmp' will have a garbage value.
Add a judgemnet to avoid this problem.
Fixes: 227f609c7c0e ("ASoC: codecs: Add support for the Infineon PEB2466 codec")
Signed-off-by: Su Hui <suhui@...china.com>
---
sound/soc/codecs/peb2466.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/peb2466.c b/sound/soc/codecs/peb2466.c
index 76ee7e3f4d9b..67ea70cef0c7 100644
--- a/sound/soc/codecs/peb2466.c
+++ b/sound/soc/codecs/peb2466.c
@@ -229,7 +229,8 @@ static int peb2466_reg_read(void *context, unsigned int reg, unsigned int *val)
case PEB2466_CMD_XOP:
case PEB2466_CMD_SOP:
ret = peb2466_read_byte(peb2466, reg, &tmp);
- *val = tmp;
+ if (!ret)
+ *val = tmp;
break;
default:
dev_err(&peb2466->spi->dev, "Not a XOP or SOP command\n");
--
2.30.2
Powered by blists - more mailing lists