* [PATCH] scsi: Have scsi_init_dev_desc_priv() use memset
@ 2023-11-08 19:28 Tom Rini
2023-11-09 1:15 ` Simon Glass
2023-11-10 16:21 ` Tom Rini
0 siblings, 2 replies; 3+ messages in thread
From: Tom Rini @ 2023-11-08 19:28 UTC (permalink / raw)
To: u-boot; +Cc: Johan Jonker
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)")
Fixes: 81bd22e935dc ("rockchip: block: blk-uclass: add bounce buffer flag to blk_desc")
Signed-off-by: Tom Rini <trini@konsulko.com>
---
Cc: Johan Jonker <jbx6244@gmail.com>
---
drivers/scsi/scsi.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 363047d0f72c..7dfe0c5e0562 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -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 */
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: Have scsi_init_dev_desc_priv() use memset
2023-11-08 19:28 [PATCH] scsi: Have scsi_init_dev_desc_priv() use memset Tom Rini
@ 2023-11-09 1:15 ` Simon Glass
2023-11-10 16:21 ` Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2023-11-09 1:15 UTC (permalink / raw)
To: Tom Rini; +Cc: u-boot, Johan Jonker
On Wed, 8 Nov 2023 at 12:28, Tom Rini <trini@konsulko.com> wrote:
>
> 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)")
> Fixes: 81bd22e935dc ("rockchip: block: blk-uclass: add bounce buffer flag to blk_desc")
> Signed-off-by: Tom Rini <trini@konsulko.com>
> ---
> Cc: Johan Jonker <jbx6244@gmail.com>
> ---
> drivers/scsi/scsi.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: Have scsi_init_dev_desc_priv() use memset
2023-11-08 19:28 [PATCH] scsi: Have scsi_init_dev_desc_priv() use memset Tom Rini
2023-11-09 1:15 ` Simon Glass
@ 2023-11-10 16:21 ` Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2023-11-10 16:21 UTC (permalink / raw)
To: u-boot; +Cc: Johan Jonker
[-- Attachment #1: Type: text/plain, Size: 785 bytes --]
On Wed, Nov 08, 2023 at 02:28:11PM -0500, Tom Rini wrote:
> 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)")
> Fixes: 81bd22e935dc ("rockchip: block: blk-uclass: add bounce buffer flag to blk_desc")
> Signed-off-by: Tom Rini <trini@konsulko.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
Applied to u-boot/master, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-10 16:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-08 19:28 [PATCH] scsi: Have scsi_init_dev_desc_priv() use memset Tom Rini
2023-11-09 1:15 ` Simon Glass
2023-11-10 16:21 ` Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox