All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: hpsa: Avoid using dev uninitialized in hpsa_eh_device_reset_handler
@ 2019-05-23  1:38 Nathan Chancellor
  0 siblings, 0 replies; only message in thread
From: Nathan Chancellor @ 2019-05-23  1:38 UTC (permalink / raw)
  To: Don Brace
  Cc: James E.J. Bottomley, Martin K. Petersen, esc.storagedev,
	linux-scsi, linux-kernel, Nick Desaulniers, clang-built-linux,
	Nathan Chancellor

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-23  1:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-23  1:38 [PATCH] scsi: hpsa: Avoid using dev uninitialized in hpsa_eh_device_reset_handler Nathan Chancellor

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.