lkml.org 
[lkml]   [2023]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] platform/chrome: cros_ec_lpc: initialize the buf variable
Date
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.

Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/platform/chrome/cros_ec_lpc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index 3708fa75feb1..68bba0fcafab 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -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;

/*
--
2.27.0
\
 
 \ /
  Last update: 2023-03-26 23:35    [W:0.038 / U:1.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site