aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2018-06-12 17:04:20 -0400
committerKees Cook <keescook@chromium.org>2018-06-12 19:19:22 -0400
commit590b5b7d8671e011d1a8e1ab20c60addb249d015 (patch)
treec7c75c025eff2bc74ef175e1dac5b69658520748
parent6396bb221514d2876fd6dc0aa2a1f240d99b37bb (diff)
treewide: kzalloc_node() -> kcalloc_node()
The kzalloc_node() function has a 2-factor argument form, kcalloc_node(). This patch replaces cases of: kzalloc_node(a * b, gfp, node) with: kcalloc_node(a * b, gfp, node) as well as handling cases of: kzalloc_node(a * b * c, gfp, node) with: kzalloc_node(array3_size(a, b, c), gfp, node) as it's slightly less ugly than: kcalloc_node(array_size(a, b), c, gfp, node) This does, however, attempt to ignore constant size factors like: kzalloc_node(4 * 1024, gfp, node) 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_node( - (sizeof(TYPE)) * E + sizeof(TYPE) * E , ...) | kzalloc_node( - (sizeof(THING)) * E + sizeof(THING) * E , ...) ) // Drop single-byte sizes and redundant parens. @@ expression COUNT; typedef u8; typedef __u8; @@ ( kzalloc_node( - sizeof(u8) * (COUNT) + COUNT , ...) | kzalloc_node( - sizeof(__u8) * (COUNT) + COUNT , ...) | kzalloc_node( - sizeof(char) * (COUNT) + COUNT , ...) | kzalloc_node( - sizeof(unsigned char) * (COUNT) + COUNT , ...) | kzalloc_node( - sizeof(u8) * COUNT + COUNT , ...) | kzalloc_node( - sizeof(__u8) * COUNT + COUNT , ...) | kzalloc_node( - sizeof(char) * COUNT + COUNT , ...) | kzalloc_node( - 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_node + kcalloc_node ( - sizeof(TYPE) * (COUNT_ID) + COUNT_ID, sizeof(TYPE) , ...) | - kzalloc_node + kcalloc_node ( - sizeof(TYPE) * COUNT_ID + COUNT_ID, sizeof(TYPE) , ...) | - kzalloc_node + kcalloc_node ( - sizeof(TYPE) * (COUNT_CONST) + COUNT_CONST, sizeof(TYPE) , ...) | - kzalloc_node + kcalloc_node ( - sizeof(TYPE) * COUNT_CONST + COUNT_CONST, sizeof(TYPE) , ...) | - kzalloc_node + kcalloc_node ( - sizeof(THING) * (COUNT_ID) + COUNT_ID, sizeof(THING) , ...) | - kzalloc_node + kcalloc_node ( - sizeof(THING) * COUNT_ID + COUNT_ID, sizeof(THING) , ...) | - kzalloc_node + kcalloc_node ( - sizeof(THING) * (COUNT_CONST) + COUNT_CONST, sizeof(THING) , ...) | - kzalloc_node + kcalloc_node ( - sizeof(THING) * COUNT_CONST + COUNT_CONST, sizeof(THING) , ...) ) // 2-factor product, only identifiers. @@ identifier SIZE, COUNT; @@ - kzalloc_node + kcalloc_node ( - 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_node( - sizeof(TYPE) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc_node( - sizeof(TYPE) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc_node( - sizeof(TYPE) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc_node( - sizeof(TYPE) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc_node( - sizeof(THING) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kzalloc_node( - sizeof(THING) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kzalloc_node( - sizeof(THING) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kzalloc_node( - 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_node( - sizeof(TYPE1) * sizeof(TYPE2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | kzalloc_node( - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | kzalloc_node( - sizeof(THING1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | kzalloc_node( - sizeof(THING1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | kzalloc_node( - sizeof(TYPE1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) | kzalloc_node( - 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_node( - (COUNT) * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc_node( - COUNT * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc_node( - COUNT * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc_node( - (COUNT) * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc_node( - COUNT * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc_node( - (COUNT) * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc_node( - (COUNT) * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc_node( - 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_node(C1 * C2 * C3, ...) | kzalloc_node( - (E1) * E2 * E3 + array3_size(E1, E2, E3) , ...) | kzalloc_node( - (E1) * (E2) * E3 + array3_size(E1, E2, E3) , ...) | kzalloc_node( - (E1) * (E2) * (E3) + array3_size(E1, E2, E3) , ...) | kzalloc_node( - 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_node(sizeof(THING) * C2, ...) | kzalloc_node(sizeof(TYPE) * C2, ...) | kzalloc_node(C1 * C2 * C3, ...) | kzalloc_node(C1 * C2, ...) | - kzalloc_node + kcalloc_node ( - sizeof(TYPE) * (E2) + E2, sizeof(TYPE) , ...) | - kzalloc_node + kcalloc_node ( - sizeof(TYPE) * E2 + E2, sizeof(TYPE) , ...) | - kzalloc_node + kcalloc_node ( - sizeof(THING) * (E2) + E2, sizeof(THING) , ...) | - kzalloc_node + kcalloc_node ( - sizeof(THING) * E2 + E2, sizeof(THING) , ...) | - kzalloc_node + kcalloc_node ( - (E1) * E2 + E1, E2 , ...) | - kzalloc_node + kcalloc_node ( - (E1) * (E2) + E1, E2 , ...) | - kzalloc_node + kcalloc_node ( - E1 * E2 + E1, E2 , ...) ) Signed-off-by: Kees Cook <keescook@chromium.org>
-rw-r--r--block/blk-mq.c16
-rw-r--r--drivers/crypto/cavium/nitrox/nitrox_isr.c2
-rw-r--r--drivers/crypto/qat/qat_common/adf_isr.c2
-rw-r--r--drivers/crypto/virtio/virtio_crypto_algs.c2
-rw-r--r--drivers/infiniband/hw/qib/qib_init.c4
-rw-r--r--drivers/infiniband/sw/rdmavt/qp.c9
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/sge.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c10
-rw-r--r--drivers/ntb/hw/amd/ntb_hw_amd.c4
-rw-r--r--drivers/ntb/hw/intel/ntb_hw_intel.c4
-rw-r--r--drivers/ntb/ntb_transport.c4
-rw-r--r--drivers/scsi/sd_zbc.c2
-rw-r--r--drivers/usb/host/xhci-mem.c4
-rw-r--r--kernel/events/ring_buffer.c3
-rw-r--r--lib/sbitmap.c2
15 files changed, 35 insertions, 35 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index d2de0a719ab8..e9da5e6a8526 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1903,7 +1903,7 @@ struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set,
1903 if (!tags) 1903 if (!tags)
1904 return NULL; 1904 return NULL;
1905 1905
1906 tags->rqs = kzalloc_node(nr_tags * sizeof(struct request *), 1906 tags->rqs = kcalloc_node(nr_tags, sizeof(struct request *),
1907 GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY, 1907 GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY,
1908 node); 1908 node);
1909 if (!tags->rqs) { 1909 if (!tags->rqs) {
@@ -1911,9 +1911,9 @@ struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set,
1911 return NULL; 1911 return NULL;
1912 } 1912 }
1913 1913
1914 tags->static_rqs = kzalloc_node(nr_tags * sizeof(struct request *), 1914 tags->static_rqs = kcalloc_node(nr_tags, sizeof(struct request *),
1915 GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY, 1915 GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY,
1916 node); 1916 node);
1917 if (!tags->static_rqs) { 1917 if (!tags->static_rqs) {
1918 kfree(tags->rqs); 1918 kfree(tags->rqs);
1919 blk_mq_free_tags(tags); 1919 blk_mq_free_tags(tags);
@@ -2522,7 +2522,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
2522 /* init q->mq_kobj and sw queues' kobjects */ 2522 /* init q->mq_kobj and sw queues' kobjects */
2523 blk_mq_sysfs_init(q); 2523 blk_mq_sysfs_init(q);
2524 2524
2525 q->queue_hw_ctx = kzalloc_node(nr_cpu_ids * sizeof(*(q->queue_hw_ctx)), 2525 q->queue_hw_ctx = kcalloc_node(nr_cpu_ids, sizeof(*(q->queue_hw_ctx)),
2526 GFP_KERNEL, set->numa_node); 2526 GFP_KERNEL, set->numa_node);
2527 if (!q->queue_hw_ctx) 2527 if (!q->queue_hw_ctx)
2528 goto err_percpu; 2528 goto err_percpu;
@@ -2741,14 +2741,14 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
2741 if (set->nr_hw_queues > nr_cpu_ids) 2741 if (set->nr_hw_queues > nr_cpu_ids)
2742 set->nr_hw_queues = nr_cpu_ids; 2742 set->nr_hw_queues = nr_cpu_ids;
2743 2743
2744 set->tags = kzalloc_node(nr_cpu_ids * sizeof(struct blk_mq_tags *), 2744 set->tags = kcalloc_node(nr_cpu_ids, sizeof(struct blk_mq_tags *),
2745 GFP_KERNEL, set->numa_node); 2745 GFP_KERNEL, set->numa_node);
2746 if (!set->tags) 2746 if (!set->tags)
2747 return -ENOMEM; 2747 return -ENOMEM;
2748 2748
2749 ret = -ENOMEM; 2749 ret = -ENOMEM;
2750 set->mq_map = kzalloc_node(sizeof(*set->mq_map) * nr_cpu_ids, 2750 set->mq_map = kcalloc_node(nr_cpu_ids, sizeof(*set->mq_map),
2751 GFP_KERNEL, set->numa_node); 2751 GFP_KERNEL, set->numa_node);
2752 if (!set->mq_map) 2752 if (!set->mq_map)
2753 goto out_free_tags; 2753 goto out_free_tags;
2754 2754
diff --git a/drivers/crypto/cavium/nitrox/nitrox_isr.c b/drivers/crypto/cavium/nitrox/nitrox_isr.c
index dbead5f45df3..ee0d70ba25d5 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_isr.c
+++ b/drivers/crypto/cavium/nitrox/nitrox_isr.c
@@ -254,7 +254,7 @@ static int nitrox_enable_msix(struct nitrox_device *ndev)
254 * Entry 192: NPS_CORE_INT_ACTIVE 254 * Entry 192: NPS_CORE_INT_ACTIVE
255 */ 255 */
256 nr_entries = (ndev->nr_queues * NR_RING_VECTORS) + 1; 256 nr_entries = (ndev->nr_queues * NR_RING_VECTORS) + 1;
257 entries = kzalloc_node(nr_entries * sizeof(struct msix_entry), 257 entries = kcalloc_node(nr_entries, sizeof(struct msix_entry),
258 GFP_KERNEL, ndev->node); 258 GFP_KERNEL, ndev->node);
259 if (!entries) 259 if (!entries)
260 return -ENOMEM; 260 return -ENOMEM;
diff --git a/drivers/crypto/qat/qat_common/adf_isr.c b/drivers/crypto/qat/qat_common/adf_isr.c
index 06d49017a52b..cd1cdf5305bc 100644
--- a/drivers/crypto/qat/qat_common/adf_isr.c
+++ b/drivers/crypto/qat/qat_common/adf_isr.c
@@ -238,7 +238,7 @@ static int adf_isr_alloc_msix_entry_table(struct adf_accel_dev *accel_dev)
238 if (!accel_dev->pf.vf_info) 238 if (!accel_dev->pf.vf_info)
239 msix_num_entries += hw_data->num_banks; 239 msix_num_entries += hw_data->num_banks;
240 240
241 entries = kzalloc_node(msix_num_entries * sizeof(*entries), 241 entries = kcalloc_node(msix_num_entries, sizeof(*entries),
242 GFP_KERNEL, dev_to_node(&GET_DEV(accel_dev))); 242 GFP_KERNEL, dev_to_node(&GET_DEV(accel_dev)));
243 if (!entries) 243 if (!entries)
244 return -ENOMEM; 244 return -ENOMEM;
diff --git a/drivers/crypto/virtio/virtio_crypto_algs.c b/drivers/crypto/virtio/virtio_crypto_algs.c
index ba190cfa7aa1..af6a908dfa7a 100644
--- a/drivers/crypto/virtio/virtio_crypto_algs.c
+++ b/drivers/crypto/virtio/virtio_crypto_algs.c
@@ -371,7 +371,7 @@ __virtio_crypto_ablkcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req,
371 371
372 /* Why 3? outhdr + iv + inhdr */ 372 /* Why 3? outhdr + iv + inhdr */
373 sg_total = src_nents + dst_nents + 3; 373 sg_total = src_nents + dst_nents + 3;
374 sgs = kzalloc_node(sg_total * sizeof(*sgs), GFP_ATOMIC, 374 sgs = kcalloc_node(sg_total, sizeof(*sgs), GFP_ATOMIC,
375 dev_to_node(&vcrypto->vdev->dev)); 375 dev_to_node(&vcrypto->vdev->dev));
376 if (!sgs) 376 if (!sgs)
377 return -ENOMEM; 377 return -ENOMEM;
diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c
index dd4547f537f7..704505618909 100644
--- a/drivers/infiniband/hw/qib/qib_init.c
+++ b/drivers/infiniband/hw/qib/qib_init.c
@@ -1673,8 +1673,8 @@ int qib_setup_eagerbufs(struct qib_ctxtdata *rcd)
1673 size = rcd->rcvegrbuf_size; 1673 size = rcd->rcvegrbuf_size;
1674 if (!rcd->rcvegrbuf) { 1674 if (!rcd->rcvegrbuf) {
1675 rcd->rcvegrbuf = 1675 rcd->rcvegrbuf =
1676 kzalloc_node(chunk * sizeof(rcd->rcvegrbuf[0]), 1676 kcalloc_node(chunk, sizeof(rcd->rcvegrbuf[0]),
1677 GFP_KERNEL, rcd->node_id); 1677 GFP_KERNEL, rcd->node_id);
1678 if (!rcd->rcvegrbuf) 1678 if (!rcd->rcvegrbuf)
1679 goto bail; 1679 goto bail;
1680 } 1680 }
diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c
index 40046135c509..b68fde88f988 100644
--- a/drivers/infiniband/sw/rdmavt/qp.c
+++ b/drivers/infiniband/sw/rdmavt/qp.c
@@ -836,11 +836,10 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
836 RCU_INIT_POINTER(qp->next, NULL); 836 RCU_INIT_POINTER(qp->next, NULL);
837 if (init_attr->qp_type == IB_QPT_RC) { 837 if (init_attr->qp_type == IB_QPT_RC) {
838 qp->s_ack_queue = 838 qp->s_ack_queue =
839 kzalloc_node( 839 kcalloc_node(rvt_max_atomic(rdi),
840 sizeof(*qp->s_ack_queue) * 840 sizeof(*qp->s_ack_queue),
841 rvt_max_atomic(rdi), 841 GFP_KERNEL,
842 GFP_KERNEL, 842 rdi->dparms.node);
843 rdi->dparms.node);
844 if (!qp->s_ack_queue) 843 if (!qp->s_ack_queue)
845 goto bail_qp; 844 goto bail_qp;
846 } 845 }
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 7a271feec5e7..395e2a0e8d7f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -699,7 +699,7 @@ static void *alloc_ring(struct device *dev, size_t nelem, size_t elem_size,
699 if (!p) 699 if (!p)
700 return NULL; 700 return NULL;
701 if (sw_size) { 701 if (sw_size) {
702 s = kzalloc_node(nelem * sw_size, GFP_KERNEL, node); 702 s = kcalloc_node(sw_size, nelem, GFP_KERNEL, node);
703 703
704 if (!s) { 704 if (!s) {
705 dma_free_coherent(dev, len, p, *phys); 705 dma_free_coherent(dev, len, p, *phys);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 89c96a0f708e..d56752273d00 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -352,7 +352,7 @@ static int mlx5e_rq_alloc_mpwqe_info(struct mlx5e_rq *rq,
352{ 352{
353 int wq_sz = mlx5_wq_ll_get_size(&rq->mpwqe.wq); 353 int wq_sz = mlx5_wq_ll_get_size(&rq->mpwqe.wq);
354 354
355 rq->mpwqe.info = kzalloc_node(wq_sz * sizeof(*rq->mpwqe.info), 355 rq->mpwqe.info = kcalloc_node(wq_sz, sizeof(*rq->mpwqe.info),
356 GFP_KERNEL, cpu_to_node(c->cpu)); 356 GFP_KERNEL, cpu_to_node(c->cpu));
357 if (!rq->mpwqe.info) 357 if (!rq->mpwqe.info)
358 return -ENOMEM; 358 return -ENOMEM;
@@ -972,7 +972,7 @@ static int mlx5e_alloc_xdpsq_db(struct mlx5e_xdpsq *sq, int numa)
972{ 972{
973 int wq_sz = mlx5_wq_cyc_get_size(&sq->wq); 973 int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
974 974
975 sq->db.di = kzalloc_node(sizeof(*sq->db.di) * wq_sz, 975 sq->db.di = kcalloc_node(wq_sz, sizeof(*sq->db.di),
976 GFP_KERNEL, numa); 976 GFP_KERNEL, numa);
977 if (!sq->db.di) { 977 if (!sq->db.di) {
978 mlx5e_free_xdpsq_db(sq); 978 mlx5e_free_xdpsq_db(sq);
@@ -1031,7 +1031,7 @@ static int mlx5e_alloc_icosq_db(struct mlx5e_icosq *sq, int numa)
1031{ 1031{
1032 u8 wq_sz = mlx5_wq_cyc_get_size(&sq->wq); 1032 u8 wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
1033 1033
1034 sq->db.ico_wqe = kzalloc_node(sizeof(*sq->db.ico_wqe) * wq_sz, 1034 sq->db.ico_wqe = kcalloc_node(wq_sz, sizeof(*sq->db.ico_wqe),
1035 GFP_KERNEL, numa); 1035 GFP_KERNEL, numa);
1036 if (!sq->db.ico_wqe) 1036 if (!sq->db.ico_wqe)
1037 return -ENOMEM; 1037 return -ENOMEM;
@@ -1086,9 +1086,9 @@ static int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa)
1086 int wq_sz = mlx5_wq_cyc_get_size(&sq->wq); 1086 int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
1087 int df_sz = wq_sz * MLX5_SEND_WQEBB_NUM_DS; 1087 int df_sz = wq_sz * MLX5_SEND_WQEBB_NUM_DS;
1088 1088
1089 sq->db.dma_fifo = kzalloc_node(df_sz * sizeof(*sq->db.dma_fifo), 1089 sq->db.dma_fifo = kcalloc_node(df_sz, sizeof(*sq->db.dma_fifo),
1090 GFP_KERNEL, numa); 1090 GFP_KERNEL, numa);
1091 sq->db.wqe_info = kzalloc_node(wq_sz * sizeof(*sq->db.wqe_info), 1091 sq->db.wqe_info = kcalloc_node(wq_sz, sizeof(*sq->db.wqe_info),
1092 GFP_KERNEL, numa); 1092 GFP_KERNEL, numa);
1093 if (!sq->db.dma_fifo || !sq->db.wqe_info) { 1093 if (!sq->db.dma_fifo || !sq->db.wqe_info) {
1094 mlx5e_free_txqsq_db(sq); 1094 mlx5e_free_txqsq_db(sq);
diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
index 3cfa46876239..efb214fc545a 100644
--- a/drivers/ntb/hw/amd/ntb_hw_amd.c
+++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
@@ -592,12 +592,12 @@ static int ndev_init_isr(struct amd_ntb_dev *ndev,
592 ndev->db_mask = ndev->db_valid_mask; 592 ndev->db_mask = ndev->db_valid_mask;
593 593
594 /* Try to set up msix irq */ 594 /* Try to set up msix irq */
595 ndev->vec = kzalloc_node(msix_max * sizeof(*ndev->vec), 595 ndev->vec = kcalloc_node(msix_max, sizeof(*ndev->vec),
596 GFP_KERNEL, node); 596 GFP_KERNEL, node);
597 if (!ndev->vec) 597 if (!ndev->vec)
598 goto err_msix_vec_alloc; 598 goto err_msix_vec_alloc;
599 599
600 ndev->msix = kzalloc_node(msix_max * sizeof(*ndev->msix), 600 ndev->msix = kcalloc_node(msix_max, sizeof(*ndev->msix),
601 GFP_KERNEL, node); 601 GFP_KERNEL, node);
602 if (!ndev->msix) 602 if (!ndev->msix)
603 goto err_msix_alloc; 603 goto err_msix_alloc;
diff --git a/drivers/ntb/hw/intel/ntb_hw_intel.c b/drivers/ntb/hw/intel/ntb_hw_intel.c
index 156b45cd4a19..3be323132896 100644
--- a/drivers/ntb/hw/intel/ntb_hw_intel.c
+++ b/drivers/ntb/hw/intel/ntb_hw_intel.c
@@ -448,12 +448,12 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev,
448 448
449 /* Try to set up msix irq */ 449 /* Try to set up msix irq */
450 450
451 ndev->vec = kzalloc_node(msix_max * sizeof(*ndev->vec), 451 ndev->vec = kcalloc_node(msix_max, sizeof(*ndev->vec),
452 GFP_KERNEL, node); 452 GFP_KERNEL, node);
453 if (!ndev->vec) 453 if (!ndev->vec)
454 goto err_msix_vec_alloc; 454 goto err_msix_vec_alloc;
455 455
456 ndev->msix = kzalloc_node(msix_max * sizeof(*ndev->msix), 456 ndev->msix = kcalloc_node(msix_max, sizeof(*ndev->msix),
457 GFP_KERNEL, node); 457 GFP_KERNEL, node);
458 if (!ndev->msix) 458 if (!ndev->msix)
459 goto err_msix_alloc; 459 goto err_msix_alloc;
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index 9878c48826e3..504bdcc57ae8 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -1102,7 +1102,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
1102 max_mw_count_for_spads = (spad_count - MW0_SZ_HIGH) / 2; 1102 max_mw_count_for_spads = (spad_count - MW0_SZ_HIGH) / 2;
1103 nt->mw_count = min(mw_count, max_mw_count_for_spads); 1103 nt->mw_count = min(mw_count, max_mw_count_for_spads);
1104 1104
1105 nt->mw_vec = kzalloc_node(mw_count * sizeof(*nt->mw_vec), 1105 nt->mw_vec = kcalloc_node(mw_count, sizeof(*nt->mw_vec),
1106 GFP_KERNEL, node); 1106 GFP_KERNEL, node);
1107 if (!nt->mw_vec) { 1107 if (!nt->mw_vec) {
1108 rc = -ENOMEM; 1108 rc = -ENOMEM;
@@ -1143,7 +1143,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
1143 nt->qp_bitmap = qp_bitmap; 1143 nt->qp_bitmap = qp_bitmap;
1144 nt->qp_bitmap_free = qp_bitmap; 1144 nt->qp_bitmap_free = qp_bitmap;
1145 1145
1146 nt->qp_vec = kzalloc_node(qp_count * sizeof(*nt->qp_vec), 1146 nt->qp_vec = kcalloc_node(qp_count, sizeof(*nt->qp_vec),
1147 GFP_KERNEL, node); 1147 GFP_KERNEL, node);
1148 if (!nt->qp_vec) { 1148 if (!nt->qp_vec) {
1149 rc = -ENOMEM; 1149 rc = -ENOMEM;
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index 323e3dc4bc59..76da8c3a6f09 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -494,7 +494,7 @@ out_free:
494static inline unsigned long * 494static inline unsigned long *
495sd_zbc_alloc_zone_bitmap(u32 nr_zones, int numa_node) 495sd_zbc_alloc_zone_bitmap(u32 nr_zones, int numa_node)
496{ 496{
497 return kzalloc_node(BITS_TO_LONGS(nr_zones) * sizeof(unsigned long), 497 return kcalloc_node(BITS_TO_LONGS(nr_zones), sizeof(unsigned long),
498 GFP_KERNEL, numa_node); 498 GFP_KERNEL, numa_node);
499} 499}
500 500
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 4fe74711938e..acbd3d7b8828 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -2274,8 +2274,8 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
2274 xhci->hw_ports[i].hw_portnum = i; 2274 xhci->hw_ports[i].hw_portnum = i;
2275 } 2275 }
2276 2276
2277 xhci->rh_bw = kzalloc_node(sizeof(*xhci->rh_bw)*num_ports, flags, 2277 xhci->rh_bw = kcalloc_node(num_ports, sizeof(*xhci->rh_bw), flags,
2278 dev_to_node(dev)); 2278 dev_to_node(dev));
2279 if (!xhci->rh_bw) 2279 if (!xhci->rh_bw)
2280 return -ENOMEM; 2280 return -ENOMEM;
2281 for (i = 0; i < num_ports; i++) { 2281 for (i = 0; i < num_ports; i++) {
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 1d8ca9ea9979..045a37e9ddee 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -614,7 +614,8 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
614 } 614 }
615 } 615 }
616 616
617 rb->aux_pages = kzalloc_node(nr_pages * sizeof(void *), GFP_KERNEL, node); 617 rb->aux_pages = kcalloc_node(nr_pages, sizeof(void *), GFP_KERNEL,
618 node);
618 if (!rb->aux_pages) 619 if (!rb->aux_pages)
619 return -ENOMEM; 620 return -ENOMEM;
620 621
diff --git a/lib/sbitmap.c b/lib/sbitmap.c
index 6fdc6267f4a8..fdd1b8aa8ac6 100644
--- a/lib/sbitmap.c
+++ b/lib/sbitmap.c
@@ -52,7 +52,7 @@ int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift,
52 return 0; 52 return 0;
53 } 53 }
54 54
55 sb->map = kzalloc_node(sb->map_nr * sizeof(*sb->map), flags, node); 55 sb->map = kcalloc_node(sb->map_nr, sizeof(*sb->map), flags, node);
56 if (!sb->map) 56 if (!sb->map)
57 return -ENOMEM; 57 return -ENOMEM;
58 58