Skip to contentSkip to conversation

scsi: myrs: Fix uninitialized variable

PATCH Applied YueHaibing 3 participants 3 messages May 9, 2019 – May 13, 2019

Subsystems (2)
lore
Share & tools
lore

YueHaibing

author
#0 lore raw

PATCH 1/1 scsi: myrs: Fix uninitialized variable

drivers/scsi/myrs.c: In function 'myrs_log_event':
drivers/scsi/myrs.c:821:24: warning: 'sshdr.sense_key' may be used uninitialized in this function [-Wmaybe-uninitialized]
struct scsi_sense_hdr sshdr;

If ev->ev_code is not 0x1C, sshdr.sense_key may
be used uninitialized. Fix this by initializing
variable 'sshdr' to 0.

Fixes 77266186397c ("scsi: myrs: Add Mylex RAID controller (SCSI interface)")
---
 drivers/scsi/myrs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/myrs.c +1 -1
index b8d54ef..eb0dd56 100644
@@ -818,7 +818,7 @@ static void myrs_log_event(struct myrs_hba *cs, struct myrs_event *ev)
 	unsigned char ev_type, *ev_msg;
 	struct Scsi_Host *shost = cs->host;
 	struct scsi_device *sdev;
-	struct scsi_sense_hdr sshdr;
+	struct scsi_sense_hdr sshdr = {0};
 	unsigned char sense_info[4];
 	unsigned char cmd_specific[4];
 
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · YueHaibing

drivers/scsi/myrs.c: In function 'myrs_log_event':
drivers/scsi/myrs.c:821:24: warning: 'sshdr.sense_key' may be used uninitialized in this function [-Wmaybe-uninitialized]
struct scsi_sense_hdr sshdr;

If ev->ev_code is not 0x1C, sshdr.sense_key may
be used uninitialized. Fix this by initializing
variable 'sshdr' to 0.

Fixes 77266186397c ("scsi: myrs: Add Mylex RAID controller (SCSI interface)")
---
  drivers/scsi/myrs.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/myrs.c +0 -0
index b8d54ef..eb0dd56 100644

drivers/scsi/myrs.c static void myrs_log_event(struct myrs_hba *cs, struct myrs_event *ev) · line 824

Quoted 8 lines
drivers/scsi/myrs.c +1 -1
@@ -818,7 +818,7 @@ static void myrs_log_event(struct myrs_hba *cs, struct myrs_event *ev)
  	unsigned char ev_type, *ev_msg;
  	struct Scsi_Host *shost = cs->host;
  	struct scsi_device *sdev;
-	struct scsi_sense_hdr sshdr;
+	struct scsi_sense_hdr sshdr = {0};
  	unsigned char sense_info[4];
  	unsigned char cmd_specific[4];
 

Cheers,

Hannes

Signature · 5 lines
Dr. Hannes Reinecke            Teamlead Storage & Networking
[email protected]                              +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)
#2 lore raw
In reply to YueHaibing

YueHaibing,

Quoted 2 lines

If ev->ev_code is not 0x1C, sshdr.sense_key may be used uninitialized. Fix this by initializing variable 'sshdr' to 0.

Applied to 5.2/scsi-queue, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering