From: Tom Rix <trix@redhat.com>
To: bleung@chromium.org, groeck@chromium.org, nathan@kernel.org,
ndesaulniers@google.com
Cc: chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Tom Rix <trix@redhat.com>
Subject: [PATCH] platform/chrome: cros_ec_lpc: initialize the buf variable
Date: Tue, 10 Jan 2023 14:36:11 -0500 [thread overview]
Message-ID: <20230110193611.3573777-1-trix@redhat.com> (raw)
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
next reply other threads:[~2023-01-10 19:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-10 19:36 Tom Rix [this message]
2023-01-11 3:30 ` [PATCH] platform/chrome: cros_ec_lpc: initialize the buf variable patchwork-bot+chrome-platform
2023-01-13 21:20 ` patchwork-bot+chrome-platform
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230110193611.3573777-1-trix@redhat.com \
--to=trix@redhat.com \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox