LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] scsi: myrs: Fix uninitialized variable
@ 2019-05-09 15:22 YueHaibing
  2019-05-09 15:26 ` Hannes Reinecke
  2019-05-13 22:42 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: YueHaibing @ 2019-05-09 15:22 UTC (permalink / raw)
  To: hare, jejb, martin.petersen; +Cc: linux-kernel, linux-scsi, 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)")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/scsi/myrs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
index b8d54ef..eb0dd56 100644
--- a/drivers/scsi/myrs.c
+++ b/drivers/scsi/myrs.c
@@ -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];
 
-- 
2.7.4



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: myrs: Fix uninitialized variable
  2019-05-09 15:22 [PATCH] scsi: myrs: Fix uninitialized variable YueHaibing
@ 2019-05-09 15:26 ` Hannes Reinecke
  2019-05-13 22:42 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Hannes Reinecke @ 2019-05-09 15:26 UTC (permalink / raw)
  To: YueHaibing, hare, jejb, martin.petersen; +Cc: linux-kernel, linux-scsi

On 5/9/19 5:22 PM, YueHaibing wrote:
> 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)")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>   drivers/scsi/myrs.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
> index b8d54ef..eb0dd56 100644
> --- a/drivers/scsi/myrs.c
> +++ b/drivers/scsi/myrs.c
> @@ -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];
>   
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke            Teamlead Storage & Networking
hare@suse.de                              +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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: myrs: Fix uninitialized variable
  2019-05-09 15:22 [PATCH] scsi: myrs: Fix uninitialized variable YueHaibing
  2019-05-09 15:26 ` Hannes Reinecke
@ 2019-05-13 22:42 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2019-05-13 22:42 UTC (permalink / raw)
  To: YueHaibing; +Cc: hare, jejb, martin.petersen, linux-kernel, linux-scsi


YueHaibing,

> 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!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-13 22:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-09 15:22 [PATCH] scsi: myrs: Fix uninitialized variable YueHaibing
2019-05-09 15:26 ` Hannes Reinecke
2019-05-13 22:42 ` Martin K. Petersen

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).