usb: storage: debug: uninitialized var in usb_stor_show_sense()
Subsystems (4)
PATCH 1/1 usb: storage: debug: uninitialized var in usb_stor_show_sense()
The "fmt" variable might be used uninitialized, it should be set to NULL at the start.
drivers/usb/storage/debug.c +2 -1
@@ -164,7 +164,8 @@ void usb_stor_show_sense(const struct us_data *us, unsigned char asc, unsigned char ascq) { -const char *what, *keystr, *fmt; +const char *fmt =NULL ; +const char *what, *keystr; keystr =scsi_sense_key_string (key); what =scsi_extd_sense_format (asc, ascq, &fmt);
James Bottomley
maintainerQuoted 5 lines · Dan Carpenter
The "fmt" variable might be used uninitialized, it should be set to NULL at the start.
Fixes d811b848ebb7 ('scsi: use sdev as argument for sense code printing')Signed-off-by Dan Carpenter <[email protected]>
Hm, that' falls into the category of an interface that's hard to get right if every caller has to remember to set fmt to NULL.
Could you instead set *fmt to NULL in scsi_extd_sense_format()? That way the interface is much easier.
Thanks,
James
Quoted 4 lines · James Bottomley
Quoted 3 lines · Dan Carpenter
The "fmt" variable might be used uninitialized, it should be set to NULL at the start.
Quoted 9 lines
Quoted 2 lines
Fixes d811b848ebb7 ('scsi: use sdev as argument for sense code printing')Signed-off-by Dan Carpenter <[email protected]>Hm, that' falls into the category of an interface that's hard to get right if every caller has to remember to set fmt to NULL.
Could you instead set *fmt to NULL in
scsi_extd_sense_format()? That way the interface is much easier.
Sure. I will send that tomorrow.
regards,
dan carpenter
PATCH v2 1/1 scsi: set fmt to NULL scsi_extd_sense_format() by default
In reply to James BottomleyOne of the two callers passes an unintialized pointer as "fmt" and expects it to be set to NULL if there is no format string. Let's make this function work as expected.
---
v2: Change scsi_extd_sense_format() instead of the caller
drivers/scsi/constants.c +3 -0
@@ -1271,6 +1271,7 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt)int i;unsigned short code = ((asc <<8 ) | ascq); + *fmt =NULL ;for (i =0 ; additional[i].text; i++)if (additional[i].code12 = code)return additional[i].text;
@@ -1282,6 +1283,8 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt) return additional2[i].str; } } +#else + *fmt =NULL ;#endif return NULL ; }
Re: [patch v2] scsi: set fmt to NULL scsi_extd_sense_format() by default
Quoted 8 lines · Dan Carpenter
One of the two callers passes an unintialized pointer as "fmt" and expects it to be set to NULL if there is no format string. Let's make this function work as expected.
Fixes d811b848ebb7 ('scsi: use sdev as argument for sense code printing')Signed-off-by Dan Carpenter <[email protected]>---
v2: Changescsi_extd_sense_format()instead of the caller
James