From: Nathan Chancellor <natechancellor@gmail.com>
To: Don Brace <don.brace@microsemi.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
esc.storagedev@microsemi.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org,
Nick Desaulniers <ndesaulniers@google.com>,
clang-built-linux@googlegroups.com,
Nathan Chancellor <natechancellor@gmail.com>
Subject: [PATCH] scsi: hpsa: Avoid using dev uninitialized in hpsa_eh_device_reset_handler
Date: Wed, 22 May 2019 18:38:59 -0700 [thread overview]
Message-ID: <20190523013859.14778-1-natechancellor@gmail.com> (raw)
Clang warns:
drivers/scsi/hpsa.c:5964:6: warning: variable 'dev' is used
uninitialized whenever 'if' condition is true
[-Wsometimes-uninitialized]
if (lockup_detected(h)) {
^~~~~~~~~~~~~~~~~~
drivers/scsi/hpsa.c:6042:6: note: uninitialized use occurs here
if (dev)
^~~
drivers/scsi/hpsa.c:5964:2: note: remove the 'if' if its condition is
always false
if (lockup_detected(h)) {
^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/hpsa.c:5950:29: note: initialize the variable 'dev' to
silence this warning
struct hpsa_scsi_dev_t *dev;
^
= NULL
1 warning generated.
dev is potentially used uninitialized in the return_reset_status block
for a NULL check if the first 'if (lockup_detected(h))' is taken, as
dev is initialized right after that block. Initialize dev to NULL in
its declaration so that it can be safely checked within the
return_reset_status block.
Fixes: 14991a5bade5 ("scsi: hpsa: correct device resets")
Link: https://github.com/ClangBuiltLinux/linux/issues/492
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/scsi/hpsa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index c560a4532733..ac8338b0571b 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -5947,7 +5947,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
int rc = SUCCESS;
int i;
struct ctlr_info *h;
- struct hpsa_scsi_dev_t *dev;
+ struct hpsa_scsi_dev_t *dev = NULL;
u8 reset_type;
char msg[48];
unsigned long flags;
--
2.22.0.rc1
reply other threads:[~2019-05-23 1:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20190523013859.14778-1-natechancellor@gmail.com \
--to=natechancellor@gmail.com \
--cc=clang-built-linux@googlegroups.com \
--cc=don.brace@microsemi.com \
--cc=esc.storagedev@microsemi.com \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--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;
as well as URLs for NNTP newsgroup(s).