Re: [PATCH][next] scsi: fnic: Replace vmalloc() + memset() with vzalloc() and use array_size()

From: Joe Perches
Date: Tue Jun 16 2020 - 00:42:27 EST


On Tue, 2020-06-16 at 00:19 +0000, Satish Kharat (satishkh) wrote:
> Reviewed-by: Satish Kharat <satishkh@xxxxxxxxx>
> ï
>
> On 6/15/20, 3:49 PM, "Gustavo A. R. Silva" <gustavoars@xxxxxxxxxx> wrote:
>
> Use vzalloc() instead of the vmalloc() and memset. Also, use array_size()
> instead of the open-coded version.
>
> This issue was found with the help of Coccinelle and, audited and fixed
> manually.
>
> Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83
> Signed-off-by: Gustavo A. R. Silva <gustavoars@xxxxxxxxxx>
> ---
> drivers/scsi/fnic/fnic_trace.c | 16 ++++------------
> 1 file changed, 4 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
[]
> @@ -488,7 +488,7 @@ int fnic_trace_buf_init(void)
> }
>
> fnic_trace_entries.page_offset =
> - vmalloc(array_size(fnic_max_trace_entries,
> + vzalloc(array_size(fnic_max_trace_entries,
> sizeof(unsigned long)));

Perhaps better as
kvcalloc(fnic_max_trace_entries, sizeof(unsigned long),
GFP_KERNEL);