scsi: Have scsi_init_dev_desc_priv() use memset
PATCH 1/1 scsi: Have scsi_init_dev_desc_priv() use memset
When we do not have CONFIG_BOUNCE_BUFFER enabled, inside of scsi_init_dev_desc_priv we never set the 'bb' field to false, we only initialize it to true when CONFIG_BOUNCE_BUFFER is set. Given that we have a number of other fields here we had been explicitly setting to zero, change to first calling memset to clear the struct and then initialize only the fields that need non-zero default values.
Addresses-Coverity-ID: 467407 ("Uninitialized variables (UNINIT)")
---
Cc: Johan Jonker <[email protected]>
--- drivers/scsi/scsi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/scsi/scsi.c +1 -4
@@ -368,15 +368,12 @@ static void scsi_setup_test_unit_ready(struct scsi_cmd *pccb)*/ static void scsi_init_dev_desc_priv (struct blk_desc *dev_desc) { +memset (dev_desc,0 ,sizeof (struct blk_desc )); dev_desc->target =0xff ; dev_desc->lun =0xff ; dev_desc->log2blksz =LOG2_INVALID (typeof (dev_desc->log2blksz)); dev_desc->type =DEV_TYPE_UNKNOWN ; - dev_desc->vendor[0 ] =0 ; - dev_desc->product[0 ] =0 ; - dev_desc->revision[0 ] =0 ; - dev_desc->removable = false;#if IS_ENABLED (CONFIG_BOUNCE_BUFFER ) dev_desc->bb = true;#endif /* CONFIG_BOUNCE_BUFFER */
Signature · 1 line
2.34.1
Quoted 8 lines · Tom Rini
When we do not have
CONFIG_BOUNCE_BUFFERenabled, inside ofscsi_init_dev_desc_privwe never set the 'bb' field to false, we only initialize it to true whenCONFIG_BOUNCE_BUFFERis set. Given that we have a number of other fields here we had been explicitly setting to zero, change to first calling memset to clear the struct and then initialize only the fields that need non-zero default values.
Quoted 8 lines
Addresses-Coverity-ID: 467407 ("Uninitialized variables (UNINIT)")
Fixes 81bd22e935dc ("rockchip: block: blk-uclass: add bounce buffer flag to blk_desc")Signed-off-by Tom Rini <[email protected]>---
Cc: Johan Jonker <[email protected]>--- drivers/scsi/scsi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Quoted 11 lines · Tom Rini
When we do not have
CONFIG_BOUNCE_BUFFERenabled, inside ofscsi_init_dev_desc_privwe never set the 'bb' field to false, we only initialize it to true whenCONFIG_BOUNCE_BUFFERis set. Given that we have a number of other fields here we had been explicitly setting to zero, change to first calling memset to clear the struct and then initialize only the fields that need non-zero default values.Addresses-Coverity-ID: 467407 ("Uninitialized variables (UNINIT)")
Fixes 81bd22e935dc ("rockchip: block: blk-uclass: add bounce buffer flag to blk_desc")Signed-off-by Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom