Skip to contentSkip to conversation

platform/chrome: cros_ec_lpc: initialize the buf variable

PATCH Applied Tom Rix 2 participants 3 messages Jan 10, 2023 – Jan 13, 2023

Subsystems (2)
lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH 1/1 platform/chrome: cros_ec_lpc: initialize the buf variable

Clang static analysis reports this problem drivers/platform/chrome/cros_ec_lpc.c:379:13: warning: The left operand
of '!=' is a garbage value [core.UndefinedBinaryOperatorResult]

    if (buf[0] != 'E' || buf[1] != 'C') {
         ~~~~~~ ^

The check depends on the side effect of the read. When the read fails or is short, a buf containing garbage could be mistaken as correct.

---
 drivers/platform/chrome/cros_ec_lpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/chrome/cros_ec_lpc.c +1 -1
index 3708fa75feb1..68bba0fcafab 100644
@@ -350,7 +350,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
 	struct acpi_device *adev;
 	acpi_status status;
 	struct cros_ec_device *ec_dev;
-	u8 buf[2];
+	u8 buf[2] = {};
 	int irq, ret;
 
 	/*
Signature · 1 line
2.27.0
#1 lore raw
This patch was applied to chrome-platform/linux.git (for-kernelci) by Tzung-Bi Shih <[email protected]>:

Hello:

This patch was applied to chrome-platform/linux.git (for-kernelci) by Tzung-Bi Shih <[email protected]>:

Quoted 10 lines · On Tue, 10 Jan 2023 14:36:11 -0500 you wrote:

Clang static analysis reports this problem drivers/platform/chrome/cros_ec_lpc.c:379:13: warning: The left operand
of '!=' is a garbage value [core.UndefinedBinaryOperatorResult]

    if (buf[0] != 'E' || buf[1] != 'C') {
         ~~~~~~ ^

The check depends on the side effect of the read. When the read fails or is short, a buf containing garbage could be mistaken as correct.

[...]

Here is the summary with links:
- platform/chrome: cros_ec_lpc: initialize the buf variable

    https://git.kernel.org/chrome-platform/c/2ae3c610e7d2

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#2 lore raw
In reply to Tom Rix
This patch was applied to chrome-platform/linux.git (for-next) by Tzung-Bi Shih <[email protected]>:

Hello:

This patch was applied to chrome-platform/linux.git (for-next) by Tzung-Bi Shih <[email protected]>:

Quoted 10 lines · On Tue, 10 Jan 2023 14:36:11 -0500 you wrote:

Clang static analysis reports this problem drivers/platform/chrome/cros_ec_lpc.c:379:13: warning: The left operand
of '!=' is a garbage value [core.UndefinedBinaryOperatorResult]

    if (buf[0] != 'E' || buf[1] != 'C') {
         ~~~~~~ ^

The check depends on the side effect of the read. When the read fails or is short, a buf containing garbage could be mistaken as correct.

[...]

Here is the summary with links:
- platform/chrome: cros_ec_lpc: initialize the buf variable

    https://git.kernel.org/chrome-platform/c/2ae3c610e7d2

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html