aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Meyer <thomas@m3y3r.de>2011-11-29 06:08:00 -0500
committerDavid S. Miller <davem@davemloft.net>2011-12-04 01:32:05 -0500
commit01e23742b276cb8cb53bf727c4b1c50fae1860e7 (patch)
treeb6225cb5b5172ec54b08730c36377b0eef355ee9
parentfdf5af0daf8019cec2396cdef8fb042d80fe71fa (diff)
bnx2x: Use kcalloc instead of kzalloc to allocate array
The advantage of kcalloc is, that will prevent integer overflows which could result from the multiplication of number of elements and size and it is also a bit nicer to read. The semantic patch that makes this change is available in https://lkml.org/lkml/2011/11/25/107 Signed-off-by: Thomas Meyer <thomas@m3y3r.de> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c4
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 79695bb034d..477bc9713a6 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -3300,14 +3300,14 @@ int __devinit bnx2x_alloc_mem_bp(struct bnx2x *bp)
3300 msix_table_size = bp->igu_sb_cnt + 1; 3300 msix_table_size = bp->igu_sb_cnt + 1;
3301 3301
3302 /* fp array: RSS plus CNIC related L2 queues */ 3302 /* fp array: RSS plus CNIC related L2 queues */
3303 fp = kzalloc((BNX2X_MAX_RSS_COUNT(bp) + NON_ETH_CONTEXT_USE) * 3303 fp = kcalloc(BNX2X_MAX_RSS_COUNT(bp) + NON_ETH_CONTEXT_USE,
3304 sizeof(*fp), GFP_KERNEL); 3304 sizeof(*fp), GFP_KERNEL);
3305 if (!fp) 3305 if (!fp)
3306 goto alloc_err; 3306 goto alloc_err;
3307 bp->fp = fp; 3307 bp->fp = fp;
3308 3308
3309 /* msix table */ 3309 /* msix table */
3310 tbl = kzalloc(msix_table_size * sizeof(*tbl), GFP_KERNEL); 3310 tbl = kcalloc(msix_table_size, sizeof(*tbl), GFP_KERNEL);
3311 if (!tbl) 3311 if (!tbl)
3312 goto alloc_err; 3312 goto alloc_err;
3313 bp->msix_table = tbl; 3313 bp->msix_table = tbl;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
index 14517691f8d..a34362e9fd9 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
@@ -3342,7 +3342,7 @@ static inline int bnx2x_mcast_refresh_registry_e1(struct bnx2x *bp,
3342 if (!list_empty(&o->registry.exact_match.macs)) 3342 if (!list_empty(&o->registry.exact_match.macs))
3343 return 0; 3343 return 0;
3344 3344
3345 elem = kzalloc(sizeof(*elem)*len, GFP_ATOMIC); 3345 elem = kcalloc(len, sizeof(*elem), GFP_ATOMIC);
3346 if (!elem) { 3346 if (!elem) {
3347 BNX2X_ERR("Failed to allocate registry memory\n"); 3347 BNX2X_ERR("Failed to allocate registry memory\n");
3348 return -ENOMEM; 3348 return -ENOMEM;