* [PATCH] ibmveth: consolidate kmalloc of array, memset 0 to kcalloc
@ 2015-12-20 14:06 Nicholas Mc Guire
2015-12-20 18:00 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Mc Guire @ 2015-12-20 14:06 UTC (permalink / raw)
To: Thomas Falcon; +Cc: netdev, linux-kernel, Nicholas Mc Guire
This is an API consolidation only. The use of kmalloc + memset to 0
is equivalent to kcalloc in this case as it is allocating an array
of elements.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---
Found by coccinelle script (relaxed version of
scripts/coccinelle/api/alloc/kzalloc-simple.cocci)
Patch was compile tested with: ppc64_defconfig
(implies CONFIG_IBMVETH=m)
Patch is against linux-next (localversion-next is -next-20150518)
drivers/net/ethernet/ibm/ibmveth.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index 6691b5a..05f5e81 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -169,7 +169,7 @@ static int ibmveth_alloc_buffer_pool(struct ibmveth_buff_pool *pool)
if (!pool->free_map)
return -1;
- pool->dma_addr = kmalloc(sizeof(dma_addr_t) * pool->size, GFP_KERNEL);
+ pool->dma_addr = kcalloc(pool->size, sizeof(dma_addr_t), GFP_KERNEL);
if (!pool->dma_addr) {
kfree(pool->free_map);
pool->free_map = NULL;
@@ -187,8 +187,6 @@ static int ibmveth_alloc_buffer_pool(struct ibmveth_buff_pool *pool)
return -1;
}
- memset(pool->dma_addr, 0, sizeof(dma_addr_t) * pool->size);
-
for (i = 0; i < pool->size; ++i)
pool->free_map[i] = i;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ibmveth: consolidate kmalloc of array, memset 0 to kcalloc
2015-12-20 14:06 [PATCH] ibmveth: consolidate kmalloc of array, memset 0 to kcalloc Nicholas Mc Guire
@ 2015-12-20 18:00 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-12-20 18:00 UTC (permalink / raw)
To: hofrat; +Cc: tlfalcon, netdev, linux-kernel
From: Nicholas Mc Guire <hofrat@osadl.org>
Date: Sun, 20 Dec 2015 15:06:18 +0100
> This is an API consolidation only. The use of kmalloc + memset to 0
> is equivalent to kcalloc in this case as it is allocating an array
> of elements.
>
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-20 18:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-20 14:06 [PATCH] ibmveth: consolidate kmalloc of array, memset 0 to kcalloc Nicholas Mc Guire
2015-12-20 18:00 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).