2022-04-07 08:45:12

by Jiabing Wan

[permalink] [raw]
Subject: [PATCH] scsi: megaraid_sas: remove unnecessary memset

instance->cmd_list is allocated by kcalloc(). The memory is set to zero.
It is unnecessary to call memset again.

Signed-off-by: Wan Jiabing <[email protected]>
---
drivers/scsi/megaraid/megaraid_sas_base.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 8bf72dbc33b7..33f3226023f3 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4466,8 +4466,6 @@ int megasas_alloc_cmds(struct megasas_instance *instance)
return -ENOMEM;
}

- memset(instance->cmd_list, 0, sizeof(struct megasas_cmd *) *max_cmd);
-
for (i = 0; i < max_cmd; i++) {
instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd),
GFP_KERNEL);
--
2.35.1


2022-04-07 18:58:28

by Sumit Saxena

[permalink] [raw]
Subject: Re: [PATCH] scsi: megaraid_sas: remove unnecessary memset

On Thu, Apr 7, 2022 at 12:55 PM Wan Jiabing <[email protected]> wrote:
>
> instance->cmd_list is allocated by kcalloc(). The memory is set to zero.
> It is unnecessary to call memset again.
>
> Signed-off-by: Wan Jiabing <[email protected]>
Thank you.
Acked-by: Sumit Saxena <[email protected]>
> ---
> drivers/scsi/megaraid/megaraid_sas_base.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
> index 8bf72dbc33b7..33f3226023f3 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> @@ -4466,8 +4466,6 @@ int megasas_alloc_cmds(struct megasas_instance *instance)
> return -ENOMEM;
> }
>
> - memset(instance->cmd_list, 0, sizeof(struct megasas_cmd *) *max_cmd);
> -
> for (i = 0; i < max_cmd; i++) {
> instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd),
> GFP_KERNEL);
> --
> 2.35.1
>


Attachments:
smime.p7s (4.11 kB)
S/MIME Cryptographic Signature

2022-04-12 06:46:26

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH] scsi: megaraid_sas: remove unnecessary memset


Wan,

> instance->cmd_list is allocated by kcalloc(). The memory is set to
> zero. It is unnecessary to call memset again.

Applied to 5.19/scsi-staging, thanks!

--
Martin K. Petersen Oracle Linux Engineering