diff options
| author | Kees Cook <keescook@chromium.org> | 2018-06-12 17:03:40 -0400 |
|---|---|---|
| committer | Kees Cook <keescook@chromium.org> | 2018-06-12 19:19:22 -0400 |
| commit | 6396bb221514d2876fd6dc0aa2a1f240d99b37bb (patch) | |
| tree | c5c501e859b93de096b1f01160135612ed765059 /drivers/net/ethernet | |
| parent | 6da2ec56059c3c7a7e5f729e6349e74ace1e5c57 (diff) | |
treewide: kzalloc() -> kcalloc()
The kzalloc() function has a 2-factor argument form, kcalloc(). This
patch replaces cases of:
kzalloc(a * b, gfp)
with:
kcalloc(a * b, gfp)
as well as handling cases of:
kzalloc(a * b * c, gfp)
with:
kzalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kzalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kzalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
kzalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kzalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
kzalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
- kzalloc
+ kcalloc
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
kzalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
kzalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
kzalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
kzalloc(sizeof(THING) * C2, ...)
|
kzalloc(sizeof(TYPE) * C2, ...)
|
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(C1 * C2, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * E2
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'drivers/net/ethernet')
34 files changed, 123 insertions, 101 deletions
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c index 14a59e51db67..897302adc38e 100644 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c | |||
| @@ -2150,7 +2150,7 @@ static int bcm_enetsw_open(struct net_device *dev) | |||
| 2150 | priv->tx_desc_alloc_size = size; | 2150 | priv->tx_desc_alloc_size = size; |
| 2151 | priv->tx_desc_cpu = p; | 2151 | priv->tx_desc_cpu = p; |
| 2152 | 2152 | ||
| 2153 | priv->tx_skb = kzalloc(sizeof(struct sk_buff *) * priv->tx_ring_size, | 2153 | priv->tx_skb = kcalloc(priv->tx_ring_size, sizeof(struct sk_buff *), |
| 2154 | GFP_KERNEL); | 2154 | GFP_KERNEL); |
| 2155 | if (!priv->tx_skb) { | 2155 | if (!priv->tx_skb) { |
| 2156 | dev_err(kdev, "cannot allocate rx skb queue\n"); | 2156 | dev_err(kdev, "cannot allocate rx skb queue\n"); |
| @@ -2164,7 +2164,7 @@ static int bcm_enetsw_open(struct net_device *dev) | |||
| 2164 | spin_lock_init(&priv->tx_lock); | 2164 | spin_lock_init(&priv->tx_lock); |
| 2165 | 2165 | ||
| 2166 | /* init & fill rx ring with skbs */ | 2166 | /* init & fill rx ring with skbs */ |
| 2167 | priv->rx_skb = kzalloc(sizeof(struct sk_buff *) * priv->rx_ring_size, | 2167 | priv->rx_skb = kcalloc(priv->rx_ring_size, sizeof(struct sk_buff *), |
| 2168 | GFP_KERNEL); | 2168 | GFP_KERNEL); |
| 2169 | if (!priv->rx_skb) { | 2169 | if (!priv->rx_skb) { |
| 2170 | dev_err(kdev, "cannot allocate rx skb queue\n"); | 2170 | dev_err(kdev, "cannot allocate rx skb queue\n"); |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c index ffa7959f6b31..dc77bfded865 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | |||
| @@ -571,7 +571,7 @@ int bnx2x_vf_mcast(struct bnx2x *bp, struct bnx2x_virtf *vf, | |||
| 571 | else | 571 | else |
| 572 | set_bit(RAMROD_COMP_WAIT, &mcast.ramrod_flags); | 572 | set_bit(RAMROD_COMP_WAIT, &mcast.ramrod_flags); |
| 573 | if (mc_num) { | 573 | if (mc_num) { |
| 574 | mc = kzalloc(mc_num * sizeof(struct bnx2x_mcast_list_elem), | 574 | mc = kcalloc(mc_num, sizeof(struct bnx2x_mcast_list_elem), |
| 575 | GFP_KERNEL); | 575 | GFP_KERNEL); |
| 576 | if (!mc) { | 576 | if (!mc) { |
| 577 | BNX2X_ERR("Cannot Configure multicasts due to lack of memory\n"); | 577 | BNX2X_ERR("Cannot Configure multicasts due to lack of memory\n"); |
| @@ -1253,8 +1253,9 @@ int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param, | |||
| 1253 | num_vfs_param, iov->nr_virtfn); | 1253 | num_vfs_param, iov->nr_virtfn); |
| 1254 | 1254 | ||
| 1255 | /* allocate the vf array */ | 1255 | /* allocate the vf array */ |
| 1256 | bp->vfdb->vfs = kzalloc(sizeof(struct bnx2x_virtf) * | 1256 | bp->vfdb->vfs = kcalloc(BNX2X_NR_VIRTFN(bp), |
| 1257 | BNX2X_NR_VIRTFN(bp), GFP_KERNEL); | 1257 | sizeof(struct bnx2x_virtf), |
| 1258 | GFP_KERNEL); | ||
| 1258 | if (!bp->vfdb->vfs) { | 1259 | if (!bp->vfdb->vfs) { |
| 1259 | BNX2X_ERR("failed to allocate vf array\n"); | 1260 | BNX2X_ERR("failed to allocate vf array\n"); |
| 1260 | err = -ENOMEM; | 1261 | err = -ENOMEM; |
| @@ -1278,9 +1279,9 @@ int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param, | |||
| 1278 | } | 1279 | } |
| 1279 | 1280 | ||
| 1280 | /* allocate the queue arrays for all VFs */ | 1281 | /* allocate the queue arrays for all VFs */ |
| 1281 | bp->vfdb->vfqs = kzalloc( | 1282 | bp->vfdb->vfqs = kcalloc(BNX2X_MAX_NUM_VF_QUEUES, |
| 1282 | BNX2X_MAX_NUM_VF_QUEUES * sizeof(struct bnx2x_vf_queue), | 1283 | sizeof(struct bnx2x_vf_queue), |
| 1283 | GFP_KERNEL); | 1284 | GFP_KERNEL); |
| 1284 | 1285 | ||
| 1285 | if (!bp->vfdb->vfqs) { | 1286 | if (!bp->vfdb->vfqs) { |
| 1286 | BNX2X_ERR("failed to allocate vf queue array\n"); | 1287 | BNX2X_ERR("failed to allocate vf queue array\n"); |
diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c index 8bc126a156e8..30273a7717e2 100644 --- a/drivers/net/ethernet/broadcom/cnic.c +++ b/drivers/net/ethernet/broadcom/cnic.c | |||
| @@ -660,7 +660,7 @@ static int cnic_init_id_tbl(struct cnic_id_tbl *id_tbl, u32 size, u32 start_id, | |||
| 660 | id_tbl->max = size; | 660 | id_tbl->max = size; |
| 661 | id_tbl->next = next; | 661 | id_tbl->next = next; |
| 662 | spin_lock_init(&id_tbl->lock); | 662 | spin_lock_init(&id_tbl->lock); |
| 663 | id_tbl->table = kzalloc(DIV_ROUND_UP(size, 32) * 4, GFP_KERNEL); | 663 | id_tbl->table = kcalloc(DIV_ROUND_UP(size, 32), 4, GFP_KERNEL); |
| 664 | if (!id_tbl->table) | 664 | if (!id_tbl->table) |
| 665 | return -ENOMEM; | 665 | return -ENOMEM; |
| 666 | 666 | ||
| @@ -1255,13 +1255,13 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | |||
| 1255 | cp->fcoe_init_cid = 0x10; | 1255 | cp->fcoe_init_cid = 0x10; |
| 1256 | } | 1256 | } |
| 1257 | 1257 | ||
| 1258 | cp->iscsi_tbl = kzalloc(sizeof(struct cnic_iscsi) * MAX_ISCSI_TBL_SZ, | 1258 | cp->iscsi_tbl = kcalloc(MAX_ISCSI_TBL_SZ, sizeof(struct cnic_iscsi), |
| 1259 | GFP_KERNEL); | 1259 | GFP_KERNEL); |
| 1260 | if (!cp->iscsi_tbl) | 1260 | if (!cp->iscsi_tbl) |
| 1261 | goto error; | 1261 | goto error; |
| 1262 | 1262 | ||
| 1263 | cp->ctx_tbl = kzalloc(sizeof(struct cnic_context) * | 1263 | cp->ctx_tbl = kcalloc(cp->max_cid_space, sizeof(struct cnic_context), |
| 1264 | cp->max_cid_space, GFP_KERNEL); | 1264 | GFP_KERNEL); |
| 1265 | if (!cp->ctx_tbl) | 1265 | if (!cp->ctx_tbl) |
| 1266 | goto error; | 1266 | goto error; |
| 1267 | 1267 | ||
| @@ -4100,7 +4100,7 @@ static int cnic_cm_alloc_mem(struct cnic_dev *dev) | |||
| 4100 | struct cnic_local *cp = dev->cnic_priv; | 4100 | struct cnic_local *cp = dev->cnic_priv; |
| 4101 | u32 port_id; | 4101 | u32 port_id; |
| 4102 | 4102 | ||
| 4103 | cp->csk_tbl = kzalloc(sizeof(struct cnic_sock) * MAX_CM_SK_TBL_SZ, | 4103 | cp->csk_tbl = kcalloc(MAX_CM_SK_TBL_SZ, sizeof(struct cnic_sock), |
| 4104 | GFP_KERNEL); | 4104 | GFP_KERNEL); |
| 4105 | if (!cp->csk_tbl) | 4105 | if (!cp->csk_tbl) |
| 4106 | return -ENOMEM; | 4106 | return -ENOMEM; |
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 9f59b1270a7c..3be87efdc93d 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c | |||
| @@ -8631,8 +8631,9 @@ static int tg3_mem_tx_acquire(struct tg3 *tp) | |||
| 8631 | tnapi++; | 8631 | tnapi++; |
| 8632 | 8632 | ||
| 8633 | for (i = 0; i < tp->txq_cnt; i++, tnapi++) { | 8633 | for (i = 0; i < tp->txq_cnt; i++, tnapi++) { |
| 8634 | tnapi->tx_buffers = kzalloc(sizeof(struct tg3_tx_ring_info) * | 8634 | tnapi->tx_buffers = kcalloc(TG3_TX_RING_SIZE, |
| 8635 | TG3_TX_RING_SIZE, GFP_KERNEL); | 8635 | sizeof(struct tg3_tx_ring_info), |
| 8636 | GFP_KERNEL); | ||
| 8636 | if (!tnapi->tx_buffers) | 8637 | if (!tnapi->tx_buffers) |
| 8637 | goto err_out; | 8638 | goto err_out; |
| 8638 | 8639 | ||
diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c index 69cc3e0119d6..ea5f32ea308a 100644 --- a/drivers/net/ethernet/brocade/bna/bnad.c +++ b/drivers/net/ethernet/brocade/bna/bnad.c | |||
| @@ -3141,7 +3141,7 @@ bnad_set_rx_ucast_fltr(struct bnad *bnad) | |||
| 3141 | if (uc_count > bna_attr(&bnad->bna)->num_ucmac) | 3141 | if (uc_count > bna_attr(&bnad->bna)->num_ucmac) |
| 3142 | goto mode_default; | 3142 | goto mode_default; |
| 3143 | 3143 | ||
| 3144 | mac_list = kzalloc(uc_count * ETH_ALEN, GFP_ATOMIC); | 3144 | mac_list = kcalloc(ETH_ALEN, uc_count, GFP_ATOMIC); |
| 3145 | if (mac_list == NULL) | 3145 | if (mac_list == NULL) |
| 3146 | goto mode_default; | 3146 | goto mode_default; |
| 3147 | 3147 | ||
| @@ -3182,7 +3182,7 @@ bnad_set_rx_mcast_fltr(struct bnad *bnad) | |||
| 3182 | if (mc_count > bna_attr(&bnad->bna)->num_mcmac) | 3182 | if (mc_count > bna_attr(&bnad->bna)->num_mcmac) |
| 3183 | goto mode_allmulti; | 3183 | goto mode_allmulti; |
| 3184 | 3184 | ||
| 3185 | mac_list = kzalloc((mc_count + 1) * ETH_ALEN, GFP_ATOMIC); | 3185 | mac_list = kcalloc(mc_count + 1, ETH_ALEN, GFP_ATOMIC); |
| 3186 | 3186 | ||
| 3187 | if (mac_list == NULL) | 3187 | if (mac_list == NULL) |
| 3188 | goto mode_allmulti; | 3188 | goto mode_allmulti; |
diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c index 2bd7c638b178..2c63afff1382 100644 --- a/drivers/net/ethernet/calxeda/xgmac.c +++ b/drivers/net/ethernet/calxeda/xgmac.c | |||
| @@ -739,7 +739,7 @@ static int xgmac_dma_desc_rings_init(struct net_device *dev) | |||
| 739 | 739 | ||
| 740 | netdev_dbg(priv->dev, "mtu [%d] bfsize [%d]\n", dev->mtu, bfsize); | 740 | netdev_dbg(priv->dev, "mtu [%d] bfsize [%d]\n", dev->mtu, bfsize); |
| 741 | 741 | ||
| 742 | priv->rx_skbuff = kzalloc(sizeof(struct sk_buff *) * DMA_RX_RING_SZ, | 742 | priv->rx_skbuff = kcalloc(DMA_RX_RING_SZ, sizeof(struct sk_buff *), |
| 743 | GFP_KERNEL); | 743 | GFP_KERNEL); |
| 744 | if (!priv->rx_skbuff) | 744 | if (!priv->rx_skbuff) |
| 745 | return -ENOMEM; | 745 | return -ENOMEM; |
| @@ -752,7 +752,7 @@ static int xgmac_dma_desc_rings_init(struct net_device *dev) | |||
| 752 | if (!priv->dma_rx) | 752 | if (!priv->dma_rx) |
| 753 | goto err_dma_rx; | 753 | goto err_dma_rx; |
| 754 | 754 | ||
| 755 | priv->tx_skbuff = kzalloc(sizeof(struct sk_buff *) * DMA_TX_RING_SZ, | 755 | priv->tx_skbuff = kcalloc(DMA_TX_RING_SZ, sizeof(struct sk_buff *), |
| 756 | GFP_KERNEL); | 756 | GFP_KERNEL); |
| 757 | if (!priv->tx_skbuff) | 757 | if (!priv->tx_skbuff) |
| 758 | goto err_tx_skb; | 758 | goto err_tx_skb; |
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c index d42704d07484..187a249ff2d1 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c | |||
| @@ -292,8 +292,8 @@ static int nicvf_init_rbdr(struct nicvf *nic, struct rbdr *rbdr, | |||
| 292 | rbdr->is_xdp = true; | 292 | rbdr->is_xdp = true; |
| 293 | } | 293 | } |
| 294 | rbdr->pgcnt = roundup_pow_of_two(rbdr->pgcnt); | 294 | rbdr->pgcnt = roundup_pow_of_two(rbdr->pgcnt); |
| 295 | rbdr->pgcache = kzalloc(sizeof(*rbdr->pgcache) * | 295 | rbdr->pgcache = kcalloc(rbdr->pgcnt, sizeof(*rbdr->pgcache), |
| 296 | rbdr->pgcnt, GFP_KERNEL); | 296 | GFP_KERNEL); |
| 297 | if (!rbdr->pgcache) | 297 | if (!rbdr->pgcache) |
| 298 | return -ENOMEM; | 298 | return -ENOMEM; |
| 299 | rbdr->pgidx = 0; | 299 | rbdr->pgidx = 0; |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c index a95cde0fadf7..4bc211093c98 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c | |||
| @@ -561,13 +561,13 @@ int t4_uld_mem_alloc(struct adapter *adap) | |||
| 561 | if (!adap->uld) | 561 | if (!adap->uld) |
| 562 | return -ENOMEM; | 562 | return -ENOMEM; |
| 563 | 563 | ||
| 564 | s->uld_rxq_info = kzalloc(CXGB4_ULD_MAX * | 564 | s->uld_rxq_info = kcalloc(CXGB4_ULD_MAX, |
| 565 | sizeof(struct sge_uld_rxq_info *), | 565 | sizeof(struct sge_uld_rxq_info *), |
| 566 | GFP_KERNEL); | 566 | GFP_KERNEL); |
| 567 | if (!s->uld_rxq_info) | 567 | if (!s->uld_rxq_info) |
| 568 | goto err_uld; | 568 | goto err_uld; |
| 569 | 569 | ||
| 570 | s->uld_txq_info = kzalloc(CXGB4_TX_MAX * | 570 | s->uld_txq_info = kcalloc(CXGB4_TX_MAX, |
| 571 | sizeof(struct sge_uld_txq_info *), | 571 | sizeof(struct sge_uld_txq_info *), |
| 572 | GFP_KERNEL); | 572 | GFP_KERNEL); |
| 573 | if (!s->uld_txq_info) | 573 | if (!s->uld_txq_info) |
diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index ff9eb45f67f8..6d7404f66f84 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c | |||
| @@ -910,8 +910,8 @@ static int geth_setup_freeq(struct gemini_ethernet *geth) | |||
| 910 | } | 910 | } |
| 911 | 911 | ||
| 912 | /* Allocate a mapping to page look-up index */ | 912 | /* Allocate a mapping to page look-up index */ |
| 913 | geth->freeq_pages = kzalloc(pages * sizeof(*geth->freeq_pages), | 913 | geth->freeq_pages = kcalloc(pages, sizeof(*geth->freeq_pages), |
| 914 | GFP_KERNEL); | 914 | GFP_KERNEL); |
| 915 | if (!geth->freeq_pages) | 915 | if (!geth->freeq_pages) |
| 916 | goto err_freeq; | 916 | goto err_freeq; |
| 917 | geth->num_freeq_pages = pages; | 917 | geth->num_freeq_pages = pages; |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c index 1ccb6443d2ed..ef9ef703d13a 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c | |||
| @@ -2197,7 +2197,8 @@ static int hns_nic_init_ring_data(struct hns_nic_priv *priv) | |||
| 2197 | return -EINVAL; | 2197 | return -EINVAL; |
| 2198 | } | 2198 | } |
| 2199 | 2199 | ||
| 2200 | priv->ring_data = kzalloc(h->q_num * sizeof(*priv->ring_data) * 2, | 2200 | priv->ring_data = kzalloc(array3_size(h->q_num, |
| 2201 | sizeof(*priv->ring_data), 2), | ||
| 2201 | GFP_KERNEL); | 2202 | GFP_KERNEL); |
| 2202 | if (!priv->ring_data) | 2203 | if (!priv->ring_data) |
| 2203 | return -ENOMEM; | 2204 | return -ENOMEM; |
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index acf1e8b52b8e..3ba0c90e7055 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c | |||
| @@ -3312,7 +3312,7 @@ static int e1000e_write_mc_addr_list(struct net_device *netdev) | |||
| 3312 | return 0; | 3312 | return 0; |
| 3313 | } | 3313 | } |
| 3314 | 3314 | ||
| 3315 | mta_list = kzalloc(netdev_mc_count(netdev) * ETH_ALEN, GFP_ATOMIC); | 3315 | mta_list = kcalloc(netdev_mc_count(netdev), ETH_ALEN, GFP_ATOMIC); |
| 3316 | if (!mta_list) | 3316 | if (!mta_list) |
| 3317 | return -ENOMEM; | 3317 | return -ENOMEM; |
| 3318 | 3318 | ||
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index c33821d2afb3..f707709969ac 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c | |||
| @@ -3763,8 +3763,9 @@ static int igb_sw_init(struct igb_adapter *adapter) | |||
| 3763 | /* Assume MSI-X interrupts, will be checked during IRQ allocation */ | 3763 | /* Assume MSI-X interrupts, will be checked during IRQ allocation */ |
| 3764 | adapter->flags |= IGB_FLAG_HAS_MSIX; | 3764 | adapter->flags |= IGB_FLAG_HAS_MSIX; |
| 3765 | 3765 | ||
| 3766 | adapter->mac_table = kzalloc(sizeof(struct igb_mac_addr) * | 3766 | adapter->mac_table = kcalloc(hw->mac.rar_entry_count, |
| 3767 | hw->mac.rar_entry_count, GFP_ATOMIC); | 3767 | sizeof(struct igb_mac_addr), |
| 3768 | GFP_ATOMIC); | ||
| 3768 | if (!adapter->mac_table) | 3769 | if (!adapter->mac_table) |
| 3769 | return -ENOMEM; | 3770 | return -ENOMEM; |
| 3770 | 3771 | ||
| @@ -4752,7 +4753,7 @@ static int igb_write_mc_addr_list(struct net_device *netdev) | |||
| 4752 | return 0; | 4753 | return 0; |
| 4753 | } | 4754 | } |
| 4754 | 4755 | ||
| 4755 | mta_list = kzalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC); | 4756 | mta_list = kcalloc(netdev_mc_count(netdev), 6, GFP_ATOMIC); |
| 4756 | if (!mta_list) | 4757 | if (!mta_list) |
| 4757 | return -ENOMEM; | 4758 | return -ENOMEM; |
| 4758 | 4759 | ||
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 4929f7265598..0b1ba3ae159c 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | |||
| @@ -6034,8 +6034,8 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter, | |||
| 6034 | for (i = 1; i < IXGBE_MAX_LINK_HANDLE; i++) | 6034 | for (i = 1; i < IXGBE_MAX_LINK_HANDLE; i++) |
| 6035 | adapter->jump_tables[i] = NULL; | 6035 | adapter->jump_tables[i] = NULL; |
| 6036 | 6036 | ||
| 6037 | adapter->mac_table = kzalloc(sizeof(struct ixgbe_mac_addr) * | 6037 | adapter->mac_table = kcalloc(hw->mac.num_rar_entries, |
| 6038 | hw->mac.num_rar_entries, | 6038 | sizeof(struct ixgbe_mac_addr), |
| 6039 | GFP_ATOMIC); | 6039 | GFP_ATOMIC); |
| 6040 | if (!adapter->mac_table) | 6040 | if (!adapter->mac_table) |
| 6041 | return -ENOMEM; | 6041 | return -ENOMEM; |
diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c index 8a165842fa85..06ff185eb188 100644 --- a/drivers/net/ethernet/jme.c +++ b/drivers/net/ethernet/jme.c | |||
| @@ -589,8 +589,9 @@ jme_setup_tx_resources(struct jme_adapter *jme) | |||
| 589 | atomic_set(&txring->next_to_clean, 0); | 589 | atomic_set(&txring->next_to_clean, 0); |
| 590 | atomic_set(&txring->nr_free, jme->tx_ring_size); | 590 | atomic_set(&txring->nr_free, jme->tx_ring_size); |
| 591 | 591 | ||
| 592 | txring->bufinf = kzalloc(sizeof(struct jme_buffer_info) * | 592 | txring->bufinf = kcalloc(jme->tx_ring_size, |
| 593 | jme->tx_ring_size, GFP_ATOMIC); | 593 | sizeof(struct jme_buffer_info), |
| 594 | GFP_ATOMIC); | ||
| 594 | if (unlikely(!(txring->bufinf))) | 595 | if (unlikely(!(txring->bufinf))) |
| 595 | goto err_free_txring; | 596 | goto err_free_txring; |
| 596 | 597 | ||
| @@ -838,8 +839,9 @@ jme_setup_rx_resources(struct jme_adapter *jme) | |||
| 838 | rxring->next_to_use = 0; | 839 | rxring->next_to_use = 0; |
| 839 | atomic_set(&rxring->next_to_clean, 0); | 840 | atomic_set(&rxring->next_to_clean, 0); |
| 840 | 841 | ||
| 841 | rxring->bufinf = kzalloc(sizeof(struct jme_buffer_info) * | 842 | rxring->bufinf = kcalloc(jme->rx_ring_size, |
| 842 | jme->rx_ring_size, GFP_ATOMIC); | 843 | sizeof(struct jme_buffer_info), |
| 844 | GFP_ATOMIC); | ||
| 843 | if (unlikely(!(rxring->bufinf))) | 845 | if (unlikely(!(rxring->bufinf))) |
| 844 | goto err_free_rxring; | 846 | goto err_free_rxring; |
| 845 | 847 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/alloc.c b/drivers/net/ethernet/mellanox/mlx4/alloc.c index 6dabd983e7e0..4bdf25059542 100644 --- a/drivers/net/ethernet/mellanox/mlx4/alloc.c +++ b/drivers/net/ethernet/mellanox/mlx4/alloc.c | |||
| @@ -185,8 +185,8 @@ int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask, | |||
| 185 | bitmap->avail = num - reserved_top - reserved_bot; | 185 | bitmap->avail = num - reserved_top - reserved_bot; |
| 186 | bitmap->effective_len = bitmap->avail; | 186 | bitmap->effective_len = bitmap->avail; |
| 187 | spin_lock_init(&bitmap->lock); | 187 | spin_lock_init(&bitmap->lock); |
| 188 | bitmap->table = kzalloc(BITS_TO_LONGS(bitmap->max) * | 188 | bitmap->table = kcalloc(BITS_TO_LONGS(bitmap->max), sizeof(long), |
| 189 | sizeof(long), GFP_KERNEL); | 189 | GFP_KERNEL); |
| 190 | if (!bitmap->table) | 190 | if (!bitmap->table) |
| 191 | return -ENOMEM; | 191 | return -ENOMEM; |
| 192 | 192 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c index 03375c705df7..e65bc3c95630 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c | |||
| @@ -2377,20 +2377,23 @@ int mlx4_multi_func_init(struct mlx4_dev *dev) | |||
| 2377 | struct mlx4_vf_admin_state *vf_admin; | 2377 | struct mlx4_vf_admin_state *vf_admin; |
| 2378 | 2378 | ||
| 2379 | priv->mfunc.master.slave_state = | 2379 | priv->mfunc.master.slave_state = |
| 2380 | kzalloc(dev->num_slaves * | 2380 | kcalloc(dev->num_slaves, |
| 2381 | sizeof(struct mlx4_slave_state), GFP_KERNEL); | 2381 | sizeof(struct mlx4_slave_state), |
| 2382 | GFP_KERNEL); | ||
| 2382 | if (!priv->mfunc.master.slave_state) | 2383 | if (!priv->mfunc.master.slave_state) |
| 2383 | goto err_comm; | 2384 | goto err_comm; |
| 2384 | 2385 | ||
| 2385 | priv->mfunc.master.vf_admin = | 2386 | priv->mfunc.master.vf_admin = |
| 2386 | kzalloc(dev->num_slaves * | 2387 | kcalloc(dev->num_slaves, |
| 2387 | sizeof(struct mlx4_vf_admin_state), GFP_KERNEL); | 2388 | sizeof(struct mlx4_vf_admin_state), |
| 2389 | GFP_KERNEL); | ||
| 2388 | if (!priv->mfunc.master.vf_admin) | 2390 | if (!priv->mfunc.master.vf_admin) |
| 2389 | goto err_comm_admin; | 2391 | goto err_comm_admin; |
| 2390 | 2392 | ||
| 2391 | priv->mfunc.master.vf_oper = | 2393 | priv->mfunc.master.vf_oper = |
| 2392 | kzalloc(dev->num_slaves * | 2394 | kcalloc(dev->num_slaves, |
| 2393 | sizeof(struct mlx4_vf_oper_state), GFP_KERNEL); | 2395 | sizeof(struct mlx4_vf_oper_state), |
| 2396 | GFP_KERNEL); | ||
| 2394 | if (!priv->mfunc.master.vf_oper) | 2397 | if (!priv->mfunc.master.vf_oper) |
| 2395 | goto err_comm_oper; | 2398 | goto err_comm_oper; |
| 2396 | 2399 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 9670b33fc9b1..65eb06e017e4 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c | |||
| @@ -2229,13 +2229,15 @@ static int mlx4_en_copy_priv(struct mlx4_en_priv *dst, | |||
| 2229 | if (!dst->tx_ring_num[t]) | 2229 | if (!dst->tx_ring_num[t]) |
| 2230 | continue; | 2230 | continue; |
| 2231 | 2231 | ||
| 2232 | dst->tx_ring[t] = kzalloc(sizeof(struct mlx4_en_tx_ring *) * | 2232 | dst->tx_ring[t] = kcalloc(MAX_TX_RINGS, |
| 2233 | MAX_TX_RINGS, GFP_KERNEL); | 2233 | sizeof(struct mlx4_en_tx_ring *), |
| 2234 | GFP_KERNEL); | ||
| 2234 | if (!dst->tx_ring[t]) | 2235 | if (!dst->tx_ring[t]) |
| 2235 | goto err_free_tx; | 2236 | goto err_free_tx; |
| 2236 | 2237 | ||
| 2237 | dst->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) * | 2238 | dst->tx_cq[t] = kcalloc(MAX_TX_RINGS, |
| 2238 | MAX_TX_RINGS, GFP_KERNEL); | 2239 | sizeof(struct mlx4_en_cq *), |
| 2240 | GFP_KERNEL); | ||
| 2239 | if (!dst->tx_cq[t]) { | 2241 | if (!dst->tx_cq[t]) { |
| 2240 | kfree(dst->tx_ring[t]); | 2242 | kfree(dst->tx_ring[t]); |
| 2241 | goto err_free_tx; | 2243 | goto err_free_tx; |
| @@ -3320,14 +3322,16 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, | |||
| 3320 | if (!priv->tx_ring_num[t]) | 3322 | if (!priv->tx_ring_num[t]) |
| 3321 | continue; | 3323 | continue; |
| 3322 | 3324 | ||
| 3323 | priv->tx_ring[t] = kzalloc(sizeof(struct mlx4_en_tx_ring *) * | 3325 | priv->tx_ring[t] = kcalloc(MAX_TX_RINGS, |
| 3324 | MAX_TX_RINGS, GFP_KERNEL); | 3326 | sizeof(struct mlx4_en_tx_ring *), |
| 3327 | GFP_KERNEL); | ||
| 3325 | if (!priv->tx_ring[t]) { | 3328 | if (!priv->tx_ring[t]) { |
| 3326 | err = -ENOMEM; | 3329 | err = -ENOMEM; |
| 3327 | goto out; | 3330 | goto out; |
| 3328 | } | 3331 | } |
| 3329 | priv->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) * | 3332 | priv->tx_cq[t] = kcalloc(MAX_TX_RINGS, |
| 3330 | MAX_TX_RINGS, GFP_KERNEL); | 3333 | sizeof(struct mlx4_en_cq *), |
| 3334 | GFP_KERNEL); | ||
| 3331 | if (!priv->tx_cq[t]) { | 3335 | if (!priv->tx_cq[t]) { |
| 3332 | err = -ENOMEM; | 3336 | err = -ENOMEM; |
| 3333 | goto out; | 3337 | goto out; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index 0a30d81aab3b..872014702fc1 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c | |||
| @@ -2982,7 +2982,8 @@ static int mlx4_init_steering(struct mlx4_dev *dev) | |||
| 2982 | int num_entries = dev->caps.num_ports; | 2982 | int num_entries = dev->caps.num_ports; |
| 2983 | int i, j; | 2983 | int i, j; |
| 2984 | 2984 | ||
| 2985 | priv->steer = kzalloc(sizeof(struct mlx4_steer) * num_entries, GFP_KERNEL); | 2985 | priv->steer = kcalloc(num_entries, sizeof(struct mlx4_steer), |
| 2986 | GFP_KERNEL); | ||
| 2986 | if (!priv->steer) | 2987 | if (!priv->steer) |
| 2987 | return -ENOMEM; | 2988 | return -ENOMEM; |
| 2988 | 2989 | ||
| @@ -3103,7 +3104,7 @@ static u64 mlx4_enable_sriov(struct mlx4_dev *dev, struct pci_dev *pdev, | |||
| 3103 | } | 3104 | } |
| 3104 | } | 3105 | } |
| 3105 | 3106 | ||
| 3106 | dev->dev_vfs = kzalloc(total_vfs * sizeof(*dev->dev_vfs), GFP_KERNEL); | 3107 | dev->dev_vfs = kcalloc(total_vfs, sizeof(*dev->dev_vfs), GFP_KERNEL); |
| 3107 | if (NULL == dev->dev_vfs) { | 3108 | if (NULL == dev->dev_vfs) { |
| 3108 | mlx4_err(dev, "Failed to allocate memory for VFs\n"); | 3109 | mlx4_err(dev, "Failed to allocate memory for VFs\n"); |
| 3109 | goto disable_sriov; | 3110 | goto disable_sriov; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c index b0e11255a355..7b1b5ac986d0 100644 --- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | |||
| @@ -487,7 +487,7 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev) | |||
| 487 | int max_vfs_guarantee_counter = get_max_gauranteed_vfs_counter(dev); | 487 | int max_vfs_guarantee_counter = get_max_gauranteed_vfs_counter(dev); |
| 488 | 488 | ||
| 489 | priv->mfunc.master.res_tracker.slave_list = | 489 | priv->mfunc.master.res_tracker.slave_list = |
| 490 | kzalloc(dev->num_slaves * sizeof(struct slave_list), | 490 | kcalloc(dev->num_slaves, sizeof(struct slave_list), |
| 491 | GFP_KERNEL); | 491 | GFP_KERNEL); |
| 492 | if (!priv->mfunc.master.res_tracker.slave_list) | 492 | if (!priv->mfunc.master.res_tracker.slave_list) |
| 493 | return -ENOMEM; | 493 | return -ENOMEM; |
| @@ -514,14 +514,14 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev) | |||
| 514 | sizeof(int), | 514 | sizeof(int), |
| 515 | GFP_KERNEL); | 515 | GFP_KERNEL); |
| 516 | if (i == RES_MAC || i == RES_VLAN) | 516 | if (i == RES_MAC || i == RES_VLAN) |
| 517 | res_alloc->allocated = kzalloc(MLX4_MAX_PORTS * | 517 | res_alloc->allocated = |
| 518 | (dev->persist->num_vfs | 518 | kcalloc(MLX4_MAX_PORTS * |
| 519 | + 1) * | 519 | (dev->persist->num_vfs + 1), |
| 520 | sizeof(int), GFP_KERNEL); | 520 | sizeof(int), GFP_KERNEL); |
| 521 | else | 521 | else |
| 522 | res_alloc->allocated = kzalloc((dev->persist-> | 522 | res_alloc->allocated = |
| 523 | num_vfs + 1) * | 523 | kcalloc(dev->persist->num_vfs + 1, |
| 524 | sizeof(int), GFP_KERNEL); | 524 | sizeof(int), GFP_KERNEL); |
| 525 | /* Reduce the sink counter */ | 525 | /* Reduce the sink counter */ |
| 526 | if (i == RES_COUNTER) | 526 | if (i == RES_COUNTER) |
| 527 | res_alloc->res_free = dev->caps.max_counters - 1; | 527 | res_alloc->res_free = dev->caps.max_counters - 1; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c index a0433b48e833..5645a4facad2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | |||
| @@ -381,7 +381,7 @@ int mlx5_fpga_ipsec_counters_read(struct mlx5_core_dev *mdev, u64 *counters, | |||
| 381 | 381 | ||
| 382 | count = mlx5_fpga_ipsec_counters_count(mdev); | 382 | count = mlx5_fpga_ipsec_counters_count(mdev); |
| 383 | 383 | ||
| 384 | data = kzalloc(sizeof(*data) * count * 2, GFP_KERNEL); | 384 | data = kzalloc(array3_size(sizeof(*data), count, 2), GFP_KERNEL); |
| 385 | if (!data) { | 385 | if (!data) { |
| 386 | ret = -ENOMEM; | 386 | ret = -ENOMEM; |
| 387 | goto out; | 387 | goto out; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c index 857035583ccd..1e062e6b2587 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | |||
| @@ -394,8 +394,9 @@ static int mlx5_init_pin_config(struct mlx5_clock *clock) | |||
| 394 | int i; | 394 | int i; |
| 395 | 395 | ||
| 396 | clock->ptp_info.pin_config = | 396 | clock->ptp_info.pin_config = |
| 397 | kzalloc(sizeof(*clock->ptp_info.pin_config) * | 397 | kcalloc(clock->ptp_info.n_pins, |
| 398 | clock->ptp_info.n_pins, GFP_KERNEL); | 398 | sizeof(*clock->ptp_info.pin_config), |
| 399 | GFP_KERNEL); | ||
| 399 | if (!clock->ptp_info.pin_config) | 400 | if (!clock->ptp_info.pin_config) |
| 400 | return -ENOMEM; | 401 | return -ENOMEM; |
| 401 | clock->ptp_info.enable = mlx5_ptp_enable; | 402 | clock->ptp_info.enable = mlx5_ptp_enable; |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c index 91262b0573e3..cad603c35271 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | |||
| @@ -740,7 +740,8 @@ int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port) | |||
| 740 | mlxsw_sp_port->root_qdisc->prio_bitmap = 0xff; | 740 | mlxsw_sp_port->root_qdisc->prio_bitmap = 0xff; |
| 741 | mlxsw_sp_port->root_qdisc->tclass_num = MLXSW_SP_PORT_DEFAULT_TCLASS; | 741 | mlxsw_sp_port->root_qdisc->tclass_num = MLXSW_SP_PORT_DEFAULT_TCLASS; |
| 742 | 742 | ||
| 743 | mlxsw_sp_qdisc = kzalloc(sizeof(*mlxsw_sp_qdisc) * IEEE_8021QAZ_MAX_TCS, | 743 | mlxsw_sp_qdisc = kcalloc(IEEE_8021QAZ_MAX_TCS, |
| 744 | sizeof(*mlxsw_sp_qdisc), | ||
| 744 | GFP_KERNEL); | 745 | GFP_KERNEL); |
| 745 | if (!mlxsw_sp_qdisc) | 746 | if (!mlxsw_sp_qdisc) |
| 746 | goto err_tclass_qdiscs_init; | 747 | goto err_tclass_qdiscs_init; |
diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c index 52207508744c..b72d1bd11296 100644 --- a/drivers/net/ethernet/micrel/ksz884x.c +++ b/drivers/net/ethernet/micrel/ksz884x.c | |||
| @@ -4372,7 +4372,7 @@ static void ksz_update_timer(struct ksz_timer_info *info) | |||
| 4372 | */ | 4372 | */ |
| 4373 | static int ksz_alloc_soft_desc(struct ksz_desc_info *desc_info, int transmit) | 4373 | static int ksz_alloc_soft_desc(struct ksz_desc_info *desc_info, int transmit) |
| 4374 | { | 4374 | { |
| 4375 | desc_info->ring = kzalloc(sizeof(struct ksz_desc) * desc_info->alloc, | 4375 | desc_info->ring = kcalloc(desc_info->alloc, sizeof(struct ksz_desc), |
| 4376 | GFP_KERNEL); | 4376 | GFP_KERNEL); |
| 4377 | if (!desc_info->ring) | 4377 | if (!desc_info->ring) |
| 4378 | return 1; | 4378 | return 1; |
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c index c60da9e8bf14..8d0295655933 100644 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c | |||
| @@ -2220,22 +2220,22 @@ __vxge_hw_channel_allocate(struct __vxge_hw_vpath_handle *vph, | |||
| 2220 | channel->length = length; | 2220 | channel->length = length; |
| 2221 | channel->vp_id = vp_id; | 2221 | channel->vp_id = vp_id; |
| 2222 | 2222 | ||
| 2223 | channel->work_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL); | 2223 | channel->work_arr = kcalloc(length, sizeof(void *), GFP_KERNEL); |
| 2224 | if (channel->work_arr == NULL) | 2224 | if (channel->work_arr == NULL) |
| 2225 | goto exit1; | 2225 | goto exit1; |
| 2226 | 2226 | ||
| 2227 | channel->free_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL); | 2227 | channel->free_arr = kcalloc(length, sizeof(void *), GFP_KERNEL); |
| 2228 | if (channel->free_arr == NULL) | 2228 | if (channel->free_arr == NULL) |
| 2229 | goto exit1; | 2229 | goto exit1; |
| 2230 | channel->free_ptr = length; | 2230 | channel->free_ptr = length; |
| 2231 | 2231 | ||
| 2232 | channel->reserve_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL); | 2232 | channel->reserve_arr = kcalloc(length, sizeof(void *), GFP_KERNEL); |
| 2233 | if (channel->reserve_arr == NULL) | 2233 | if (channel->reserve_arr == NULL) |
| 2234 | goto exit1; | 2234 | goto exit1; |
| 2235 | channel->reserve_ptr = length; | 2235 | channel->reserve_ptr = length; |
| 2236 | channel->reserve_top = 0; | 2236 | channel->reserve_top = 0; |
| 2237 | 2237 | ||
| 2238 | channel->orig_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL); | 2238 | channel->orig_arr = kcalloc(length, sizeof(void *), GFP_KERNEL); |
| 2239 | if (channel->orig_arr == NULL) | 2239 | if (channel->orig_arr == NULL) |
| 2240 | goto exit1; | 2240 | goto exit1; |
| 2241 | 2241 | ||
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c b/drivers/net/ethernet/neterion/vxge/vxge-main.c index a8918bb7c802..5ae3fa82909f 100644 --- a/drivers/net/ethernet/neterion/vxge/vxge-main.c +++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c | |||
| @@ -3429,8 +3429,8 @@ static int vxge_device_register(struct __vxge_hw_device *hldev, | |||
| 3429 | vxge_initialize_ethtool_ops(ndev); | 3429 | vxge_initialize_ethtool_ops(ndev); |
| 3430 | 3430 | ||
| 3431 | /* Allocate memory for vpath */ | 3431 | /* Allocate memory for vpath */ |
| 3432 | vdev->vpaths = kzalloc((sizeof(struct vxge_vpath)) * | 3432 | vdev->vpaths = kcalloc(no_of_vpath, sizeof(struct vxge_vpath), |
| 3433 | no_of_vpath, GFP_KERNEL); | 3433 | GFP_KERNEL); |
| 3434 | if (!vdev->vpaths) { | 3434 | if (!vdev->vpaths) { |
| 3435 | vxge_debug_init(VXGE_ERR, | 3435 | vxge_debug_init(VXGE_ERR, |
| 3436 | "%s: vpath memory allocation failed", | 3436 | "%s: vpath memory allocation failed", |
diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c index 07a2eb3781b1..8a31a02c9f47 100644 --- a/drivers/net/ethernet/pasemi/pasemi_mac.c +++ b/drivers/net/ethernet/pasemi/pasemi_mac.c | |||
| @@ -390,8 +390,9 @@ static int pasemi_mac_setup_rx_resources(const struct net_device *dev) | |||
| 390 | spin_lock_init(&ring->lock); | 390 | spin_lock_init(&ring->lock); |
| 391 | 391 | ||
| 392 | ring->size = RX_RING_SIZE; | 392 | ring->size = RX_RING_SIZE; |
| 393 | ring->ring_info = kzalloc(sizeof(struct pasemi_mac_buffer) * | 393 | ring->ring_info = kcalloc(RX_RING_SIZE, |
| 394 | RX_RING_SIZE, GFP_KERNEL); | 394 | sizeof(struct pasemi_mac_buffer), |
| 395 | GFP_KERNEL); | ||
| 395 | 396 | ||
| 396 | if (!ring->ring_info) | 397 | if (!ring->ring_info) |
| 397 | goto out_ring_info; | 398 | goto out_ring_info; |
| @@ -473,8 +474,9 @@ pasemi_mac_setup_tx_resources(const struct net_device *dev) | |||
| 473 | spin_lock_init(&ring->lock); | 474 | spin_lock_init(&ring->lock); |
| 474 | 475 | ||
| 475 | ring->size = TX_RING_SIZE; | 476 | ring->size = TX_RING_SIZE; |
| 476 | ring->ring_info = kzalloc(sizeof(struct pasemi_mac_buffer) * | 477 | ring->ring_info = kcalloc(TX_RING_SIZE, |
| 477 | TX_RING_SIZE, GFP_KERNEL); | 478 | sizeof(struct pasemi_mac_buffer), |
| 479 | GFP_KERNEL); | ||
| 478 | if (!ring->ring_info) | 480 | if (!ring->ring_info) |
| 479 | goto out_ring_info; | 481 | goto out_ring_info; |
| 480 | 482 | ||
diff --git a/drivers/net/ethernet/qlogic/qed/qed_debug.c b/drivers/net/ethernet/qlogic/qed/qed_debug.c index b9ec460dd996..a14e48489029 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_debug.c +++ b/drivers/net/ethernet/qlogic/qed/qed_debug.c | |||
| @@ -6617,7 +6617,8 @@ static enum dbg_status qed_mcp_trace_alloc_meta(struct qed_hwfn *p_hwfn, | |||
| 6617 | 6617 | ||
| 6618 | /* Read no. of modules and allocate memory for their pointers */ | 6618 | /* Read no. of modules and allocate memory for their pointers */ |
| 6619 | meta->modules_num = qed_read_byte_from_buf(meta_buf_bytes, &offset); | 6619 | meta->modules_num = qed_read_byte_from_buf(meta_buf_bytes, &offset); |
| 6620 | meta->modules = kzalloc(meta->modules_num * sizeof(char *), GFP_KERNEL); | 6620 | meta->modules = kcalloc(meta->modules_num, sizeof(char *), |
| 6621 | GFP_KERNEL); | ||
| 6621 | if (!meta->modules) | 6622 | if (!meta->modules) |
| 6622 | return DBG_STATUS_VIRT_MEM_ALLOC_FAILED; | 6623 | return DBG_STATUS_VIRT_MEM_ALLOC_FAILED; |
| 6623 | 6624 | ||
| @@ -6645,7 +6646,7 @@ static enum dbg_status qed_mcp_trace_alloc_meta(struct qed_hwfn *p_hwfn, | |||
| 6645 | 6646 | ||
| 6646 | /* Read number of formats and allocate memory for all formats */ | 6647 | /* Read number of formats and allocate memory for all formats */ |
| 6647 | meta->formats_num = qed_read_dword_from_buf(meta_buf_bytes, &offset); | 6648 | meta->formats_num = qed_read_dword_from_buf(meta_buf_bytes, &offset); |
| 6648 | meta->formats = kzalloc(meta->formats_num * | 6649 | meta->formats = kcalloc(meta->formats_num, |
| 6649 | sizeof(struct mcp_trace_format), | 6650 | sizeof(struct mcp_trace_format), |
| 6650 | GFP_KERNEL); | 6651 | GFP_KERNEL); |
| 6651 | if (!meta->formats) | 6652 | if (!meta->formats) |
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c index b285edc8d6a1..329781cda77f 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_dev.c +++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c | |||
| @@ -814,26 +814,26 @@ static int qed_alloc_qm_data(struct qed_hwfn *p_hwfn) | |||
| 814 | if (rc) | 814 | if (rc) |
| 815 | goto alloc_err; | 815 | goto alloc_err; |
| 816 | 816 | ||
| 817 | qm_info->qm_pq_params = kzalloc(sizeof(*qm_info->qm_pq_params) * | 817 | qm_info->qm_pq_params = kcalloc(qed_init_qm_get_num_pqs(p_hwfn), |
| 818 | qed_init_qm_get_num_pqs(p_hwfn), | 818 | sizeof(*qm_info->qm_pq_params), |
| 819 | GFP_KERNEL); | 819 | GFP_KERNEL); |
| 820 | if (!qm_info->qm_pq_params) | 820 | if (!qm_info->qm_pq_params) |
| 821 | goto alloc_err; | 821 | goto alloc_err; |
| 822 | 822 | ||
| 823 | qm_info->qm_vport_params = kzalloc(sizeof(*qm_info->qm_vport_params) * | 823 | qm_info->qm_vport_params = kcalloc(qed_init_qm_get_num_vports(p_hwfn), |
| 824 | qed_init_qm_get_num_vports(p_hwfn), | 824 | sizeof(*qm_info->qm_vport_params), |
| 825 | GFP_KERNEL); | 825 | GFP_KERNEL); |
| 826 | if (!qm_info->qm_vport_params) | 826 | if (!qm_info->qm_vport_params) |
| 827 | goto alloc_err; | 827 | goto alloc_err; |
| 828 | 828 | ||
| 829 | qm_info->qm_port_params = kzalloc(sizeof(*qm_info->qm_port_params) * | 829 | qm_info->qm_port_params = kcalloc(p_hwfn->cdev->num_ports_in_engine, |
| 830 | p_hwfn->cdev->num_ports_in_engine, | 830 | sizeof(*qm_info->qm_port_params), |
| 831 | GFP_KERNEL); | 831 | GFP_KERNEL); |
| 832 | if (!qm_info->qm_port_params) | 832 | if (!qm_info->qm_port_params) |
| 833 | goto alloc_err; | 833 | goto alloc_err; |
| 834 | 834 | ||
| 835 | qm_info->wfq_data = kzalloc(sizeof(*qm_info->wfq_data) * | 835 | qm_info->wfq_data = kcalloc(qed_init_qm_get_num_vports(p_hwfn), |
| 836 | qed_init_qm_get_num_vports(p_hwfn), | 836 | sizeof(*qm_info->wfq_data), |
| 837 | GFP_KERNEL); | 837 | GFP_KERNEL); |
| 838 | if (!qm_info->wfq_data) | 838 | if (!qm_info->wfq_data) |
| 839 | goto alloc_err; | 839 | goto alloc_err; |
diff --git a/drivers/net/ethernet/qlogic/qed/qed_init_ops.c b/drivers/net/ethernet/qlogic/qed/qed_init_ops.c index 3bb76da6baa2..d9ab5add27a8 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_init_ops.c +++ b/drivers/net/ethernet/qlogic/qed/qed_init_ops.c | |||
| @@ -149,12 +149,12 @@ int qed_init_alloc(struct qed_hwfn *p_hwfn) | |||
| 149 | if (IS_VF(p_hwfn->cdev)) | 149 | if (IS_VF(p_hwfn->cdev)) |
| 150 | return 0; | 150 | return 0; |
| 151 | 151 | ||
| 152 | rt_data->b_valid = kzalloc(sizeof(bool) * RUNTIME_ARRAY_SIZE, | 152 | rt_data->b_valid = kcalloc(RUNTIME_ARRAY_SIZE, sizeof(bool), |
| 153 | GFP_KERNEL); | 153 | GFP_KERNEL); |
| 154 | if (!rt_data->b_valid) | 154 | if (!rt_data->b_valid) |
| 155 | return -ENOMEM; | 155 | return -ENOMEM; |
| 156 | 156 | ||
| 157 | rt_data->init_val = kzalloc(sizeof(u32) * RUNTIME_ARRAY_SIZE, | 157 | rt_data->init_val = kcalloc(RUNTIME_ARRAY_SIZE, sizeof(u32), |
| 158 | GFP_KERNEL); | 158 | GFP_KERNEL); |
| 159 | if (!rt_data->init_val) { | 159 | if (!rt_data->init_val) { |
| 160 | kfree(rt_data->b_valid); | 160 | kfree(rt_data->b_valid); |
diff --git a/drivers/net/ethernet/qlogic/qed/qed_l2.c b/drivers/net/ethernet/qlogic/qed/qed_l2.c index 1f6ac848109d..de1c70843efd 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_l2.c +++ b/drivers/net/ethernet/qlogic/qed/qed_l2.c | |||
| @@ -98,7 +98,7 @@ int qed_l2_alloc(struct qed_hwfn *p_hwfn) | |||
| 98 | p_l2_info->queues = max_t(u8, rx, tx); | 98 | p_l2_info->queues = max_t(u8, rx, tx); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | pp_qids = kzalloc(sizeof(unsigned long *) * p_l2_info->queues, | 101 | pp_qids = kcalloc(p_l2_info->queues, sizeof(unsigned long *), |
| 102 | GFP_KERNEL); | 102 | GFP_KERNEL); |
| 103 | if (!pp_qids) | 103 | if (!pp_qids) |
| 104 | return -ENOMEM; | 104 | return -ENOMEM; |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 1b5f7d57b6f8..8c6724063231 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | |||
| @@ -1025,15 +1025,17 @@ int qlcnic_init_pci_info(struct qlcnic_adapter *adapter) | |||
| 1025 | 1025 | ||
| 1026 | act_pci_func = ahw->total_nic_func; | 1026 | act_pci_func = ahw->total_nic_func; |
| 1027 | 1027 | ||
| 1028 | adapter->npars = kzalloc(sizeof(struct qlcnic_npar_info) * | 1028 | adapter->npars = kcalloc(act_pci_func, |
| 1029 | act_pci_func, GFP_KERNEL); | 1029 | sizeof(struct qlcnic_npar_info), |
| 1030 | GFP_KERNEL); | ||
| 1030 | if (!adapter->npars) { | 1031 | if (!adapter->npars) { |
| 1031 | ret = -ENOMEM; | 1032 | ret = -ENOMEM; |
| 1032 | goto err_pci_info; | 1033 | goto err_pci_info; |
| 1033 | } | 1034 | } |
| 1034 | 1035 | ||
| 1035 | adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) * | 1036 | adapter->eswitch = kcalloc(QLCNIC_NIU_MAX_XG_PORTS, |
| 1036 | QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL); | 1037 | sizeof(struct qlcnic_eswitch), |
| 1038 | GFP_KERNEL); | ||
| 1037 | if (!adapter->eswitch) { | 1039 | if (!adapter->eswitch) { |
| 1038 | ret = -ENOMEM; | 1040 | ret = -ENOMEM; |
| 1039 | goto err_npars; | 1041 | goto err_npars; |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c index c58180f40844..0c744b9c6e0a 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | |||
| @@ -157,8 +157,8 @@ int qlcnic_sriov_init(struct qlcnic_adapter *adapter, int num_vfs) | |||
| 157 | adapter->ahw->sriov = sriov; | 157 | adapter->ahw->sriov = sriov; |
| 158 | sriov->num_vfs = num_vfs; | 158 | sriov->num_vfs = num_vfs; |
| 159 | bc = &sriov->bc; | 159 | bc = &sriov->bc; |
| 160 | sriov->vf_info = kzalloc(sizeof(struct qlcnic_vf_info) * | 160 | sriov->vf_info = kcalloc(num_vfs, sizeof(struct qlcnic_vf_info), |
| 161 | num_vfs, GFP_KERNEL); | 161 | GFP_KERNEL); |
| 162 | if (!sriov->vf_info) { | 162 | if (!sriov->vf_info) { |
| 163 | err = -ENOMEM; | 163 | err = -ENOMEM; |
| 164 | goto qlcnic_free_sriov; | 164 | goto qlcnic_free_sriov; |
| @@ -450,7 +450,7 @@ static int qlcnic_sriov_set_guest_vlan_mode(struct qlcnic_adapter *adapter, | |||
| 450 | return 0; | 450 | return 0; |
| 451 | 451 | ||
| 452 | num_vlans = sriov->num_allowed_vlans; | 452 | num_vlans = sriov->num_allowed_vlans; |
| 453 | sriov->allowed_vlans = kzalloc(sizeof(u16) * num_vlans, GFP_KERNEL); | 453 | sriov->allowed_vlans = kcalloc(num_vlans, sizeof(u16), GFP_KERNEL); |
| 454 | if (!sriov->allowed_vlans) | 454 | if (!sriov->allowed_vlans) |
| 455 | return -ENOMEM; | 455 | return -ENOMEM; |
| 456 | 456 | ||
| @@ -706,7 +706,7 @@ static inline int qlcnic_sriov_alloc_bc_trans(struct qlcnic_bc_trans **trans) | |||
| 706 | static inline int qlcnic_sriov_alloc_bc_msg(struct qlcnic_bc_hdr **hdr, | 706 | static inline int qlcnic_sriov_alloc_bc_msg(struct qlcnic_bc_hdr **hdr, |
| 707 | u32 size) | 707 | u32 size) |
| 708 | { | 708 | { |
| 709 | *hdr = kzalloc(sizeof(struct qlcnic_bc_hdr) * size, GFP_ATOMIC); | 709 | *hdr = kcalloc(size, sizeof(struct qlcnic_bc_hdr), GFP_ATOMIC); |
| 710 | if (!*hdr) | 710 | if (!*hdr) |
| 711 | return -ENOMEM; | 711 | return -ENOMEM; |
| 712 | 712 | ||
diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index ce8071fc90c4..e080d3e7c582 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c | |||
| @@ -973,7 +973,7 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id) | |||
| 973 | goto err; | 973 | goto err; |
| 974 | } | 974 | } |
| 975 | 975 | ||
| 976 | dring->desc = kzalloc(DESC_NUM * sizeof(*dring->desc), GFP_KERNEL); | 976 | dring->desc = kcalloc(DESC_NUM, sizeof(*dring->desc), GFP_KERNEL); |
| 977 | if (!dring->desc) { | 977 | if (!dring->desc) { |
| 978 | ret = -ENOMEM; | 978 | ret = -ENOMEM; |
| 979 | goto err; | 979 | goto err; |
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c b/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c index eed18f88bdff..302079e22b06 100644 --- a/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c +++ b/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c | |||
| @@ -2320,8 +2320,9 @@ static struct net_device *gelic_wl_alloc(struct gelic_card *card) | |||
| 2320 | pr_debug("%s: wl=%p port=%p\n", __func__, wl, port); | 2320 | pr_debug("%s: wl=%p port=%p\n", __func__, wl, port); |
| 2321 | 2321 | ||
| 2322 | /* allocate scan list */ | 2322 | /* allocate scan list */ |
| 2323 | wl->networks = kzalloc(sizeof(struct gelic_wl_scan_info) * | 2323 | wl->networks = kcalloc(GELIC_WL_BSS_MAX_ENT, |
| 2324 | GELIC_WL_BSS_MAX_ENT, GFP_KERNEL); | 2324 | sizeof(struct gelic_wl_scan_info), |
| 2325 | GFP_KERNEL); | ||
| 2325 | 2326 | ||
| 2326 | if (!wl->networks) | 2327 | if (!wl->networks) |
| 2327 | goto fail_bss; | 2328 | goto fail_bss; |
