lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 27 Jan 2022 12:42:31 +0000
From:   Robin Murphy <robin.murphy@....com>
To:     Simon Horman <simon.horman@...igine.com>
Cc:     kuba@...nel.org, davem@...emloft.net, oss-drivers@...igine.com,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] nfp: nsp: Simplify array allocation

On 2022-01-27 09:06, Simon Horman wrote:
> On Wed, Jan 26, 2022 at 04:30:33PM +0000, Robin Murphy wrote:
>> Prefer kcalloc() to kzalloc(array_size()) for allocating an array.
>>
>> Signed-off-by: Robin Murphy <robin.murphy@....com>
> 
> Hi Robin,
> 
> thanks for the cleanup.
> 
> One minor nit: I think "nfp: " would be a slightly more normal prefix
> than "nfp: nsp: ".

Ah, OK - from the git history it seemed about 50/50 one way or the 
other, so I guessed at the one that looked more specific to this 
particular file. I ran into this little anti-pattern in code I was 
working on, and this was the only other instance that a quick grep 
turned up so I figured I may as well fix it too.

> That notwithstanding,
> 
> Acked-by: Simon Horman <simon.horman@...igine.com>

Thanks!
Robin.

>> ---
>>   drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
>> index 10e7d8b21c46..730fea214b8a 100644
>> --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
>> +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c
>> @@ -513,7 +513,7 @@ nfp_nsp_command_buf_dma_sg(struct nfp_nsp *nsp,
>>   	dma_size = BIT_ULL(dma_order);
>>   	nseg = DIV_ROUND_UP(max_size, chunk_size);
>>   
>> -	chunks = kzalloc(array_size(sizeof(*chunks), nseg), GFP_KERNEL);
>> +	chunks = kcalloc(nseg, sizeof(*chunks), GFP_KERNEL);
>>   	if (!chunks)
>>   		return -ENOMEM;
>>   
>> -- 
>> 2.28.0.dirty
>>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ