Skip to content

Commit

Permalink
ASoC: codecs: avoid possible garbage value in peb2466_reg_read()
Browse files Browse the repository at this point in the history
[ Upstream commit 38cc033 ]

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: 227f609 ("ASoC: codecs: Add support for the Infineon PEB2466 codec")
Signed-off-by: Su Hui <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Mark Brown <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
Su Hui authored and gregkh committed Sep 18, 2024
1 parent bcf0e7f commit d53503c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sound/soc/codecs/peb2466.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit d53503c

Please sign in to comment.