treewide: kzalloc_node() -> kcalloc_node()
authorKees Cook <keescook@chromium.org>
Tue, 12 Jun 2018 21:04:20 +0000 (14:04 -0700)
committerKees Cook <keescook@chromium.org>
Tue, 12 Jun 2018 23:19:22 +0000 (16:19 -0700)
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>
15 files changed:
block/blk-mq.c
drivers/crypto/cavium/nitrox/nitrox_isr.c
drivers/crypto/qat/qat_common/adf_isr.c
drivers/crypto/virtio/virtio_crypto_algs.c
drivers/infiniband/hw/qib/qib_init.c
drivers/infiniband/sw/rdmavt/qp.c
drivers/net/ethernet/chelsio/cxgb4/sge.c
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/ntb/hw/amd/ntb_hw_amd.c
drivers/ntb/hw/intel/ntb_hw_intel.c
drivers/ntb/ntb_transport.c
drivers/scsi/sd_zbc.c
drivers/usb/host/xhci-mem.c
kernel/events/ring_buffer.c
lib/sbitmap.c

index d2de0a719ab8018e2bf976ed4839ffc19dcff31e..e9da5e6a8526f38bb6b3e581d7661eda4c520a38 100644 (file)
@@ -1903,7 +1903,7 @@ struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set,
        if (!tags)
                return NULL;
 
-       tags->rqs = kzalloc_node(nr_tags * sizeof(struct request *),
+       tags->rqs = kcalloc_node(nr_tags, sizeof(struct request *),
                                 GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY,
                                 node);
        if (!tags->rqs) {
@@ -1911,9 +1911,9 @@ struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set,
                return NULL;
        }
 
-       tags->static_rqs = kzalloc_node(nr_tags * sizeof(struct request *),
-                                GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY,
-                                node);
+       tags->static_rqs = kcalloc_node(nr_tags, sizeof(struct request *),
+                                       GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY,
+                                       node);
        if (!tags->static_rqs) {
                kfree(tags->rqs);
                blk_mq_free_tags(tags);
@@ -2522,7 +2522,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
        /* init q->mq_kobj and sw queues' kobjects */
        blk_mq_sysfs_init(q);
 
-       q->queue_hw_ctx = kzalloc_node(nr_cpu_ids * sizeof(*(q->queue_hw_ctx)),
+       q->queue_hw_ctx = kcalloc_node(nr_cpu_ids, sizeof(*(q->queue_hw_ctx)),
                                                GFP_KERNEL, set->numa_node);
        if (!q->queue_hw_ctx)
                goto err_percpu;
@@ -2741,14 +2741,14 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
        if (set->nr_hw_queues > nr_cpu_ids)
                set->nr_hw_queues = nr_cpu_ids;
 
-       set->tags = kzalloc_node(nr_cpu_ids * sizeof(struct blk_mq_tags *),
+       set->tags = kcalloc_node(nr_cpu_ids, sizeof(struct blk_mq_tags *),
                                 GFP_KERNEL, set->numa_node);
        if (!set->tags)
                return -ENOMEM;
 
        ret = -ENOMEM;
-       set->mq_map = kzalloc_node(sizeof(*set->mq_map) * nr_cpu_ids,
-                       GFP_KERNEL, set->numa_node);
+       set->mq_map = kcalloc_node(nr_cpu_ids, sizeof(*set->mq_map),
+                                  GFP_KERNEL, set->numa_node);
        if (!set->mq_map)
                goto out_free_tags;
 
index dbead5f45df31ec3c6e0b94667fc60993186ec83..ee0d70ba25d5574c0b073bb28d5a69c250e3ccbb 100644 (file)
@@ -254,7 +254,7 @@ static int nitrox_enable_msix(struct nitrox_device *ndev)
         * Entry 192: NPS_CORE_INT_ACTIVE
         */
        nr_entries = (ndev->nr_queues * NR_RING_VECTORS) + 1;
-       entries = kzalloc_node(nr_entries * sizeof(struct msix_entry),
+       entries = kcalloc_node(nr_entries, sizeof(struct msix_entry),
                               GFP_KERNEL, ndev->node);
        if (!entries)
                return -ENOMEM;
index 06d49017a52b7ddeb8737833293e2295b84637df..cd1cdf5305bc961ebd8169004ecf304c15000c31 100644 (file)
@@ -238,7 +238,7 @@ static int adf_isr_alloc_msix_entry_table(struct adf_accel_dev *accel_dev)
        if (!accel_dev->pf.vf_info)
                msix_num_entries += hw_data->num_banks;
 
-       entries = kzalloc_node(msix_num_entries * sizeof(*entries),
+       entries = kcalloc_node(msix_num_entries, sizeof(*entries),
                               GFP_KERNEL, dev_to_node(&GET_DEV(accel_dev)));
        if (!entries)
                return -ENOMEM;
index ba190cfa7aa18b54a0caff6143058a6bb022e70c..af6a908dfa7a98ea02e37613a456d5cde84734c0 100644 (file)
@@ -371,7 +371,7 @@ __virtio_crypto_ablkcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req,
 
        /* Why 3?  outhdr + iv + inhdr */
        sg_total = src_nents + dst_nents + 3;
-       sgs = kzalloc_node(sg_total * sizeof(*sgs), GFP_ATOMIC,
+       sgs = kcalloc_node(sg_total, sizeof(*sgs), GFP_ATOMIC,
                                dev_to_node(&vcrypto->vdev->dev));
        if (!sgs)
                return -ENOMEM;
index dd4547f537f77d85a996a88bd021e2920a3b5541..70450561890981b6af333eab1ad4e72a5f3f0c02 100644 (file)
@@ -1673,8 +1673,8 @@ int qib_setup_eagerbufs(struct qib_ctxtdata *rcd)
        size = rcd->rcvegrbuf_size;
        if (!rcd->rcvegrbuf) {
                rcd->rcvegrbuf =
-                       kzalloc_node(chunk * sizeof(rcd->rcvegrbuf[0]),
-                               GFP_KERNEL, rcd->node_id);
+                       kcalloc_node(chunk, sizeof(rcd->rcvegrbuf[0]),
+                                    GFP_KERNEL, rcd->node_id);
                if (!rcd->rcvegrbuf)
                        goto bail;
        }
index 40046135c50991fb3af581c4308697ed676ccff4..b68fde88f988add13a4758f02d3777a55339bf13 100644 (file)
@@ -836,11 +836,10 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
                RCU_INIT_POINTER(qp->next, NULL);
                if (init_attr->qp_type == IB_QPT_RC) {
                        qp->s_ack_queue =
-                               kzalloc_node(
-                                       sizeof(*qp->s_ack_queue) *
-                                        rvt_max_atomic(rdi),
-                                       GFP_KERNEL,
-                                       rdi->dparms.node);
+                               kcalloc_node(rvt_max_atomic(rdi),
+                                            sizeof(*qp->s_ack_queue),
+                                            GFP_KERNEL,
+                                            rdi->dparms.node);
                        if (!qp->s_ack_queue)
                                goto bail_qp;
                }
index 7a271feec5e74063df88bdba9209008aea35aef0..395e2a0e8d7f6235a36ae9ec73ebd5141b2f24ce 100644 (file)
@@ -699,7 +699,7 @@ static void *alloc_ring(struct device *dev, size_t nelem, size_t elem_size,
        if (!p)
                return NULL;
        if (sw_size) {
-               s = kzalloc_node(nelem * sw_size, GFP_KERNEL, node);
+               s = kcalloc_node(sw_size, nelem, GFP_KERNEL, node);
 
                if (!s) {
                        dma_free_coherent(dev, len, p, *phys);
index 89c96a0f708e780d13062415f7f5e1e023343654..d56752273d003ee282f5ac23eb507f8487e687f6 100644 (file)
@@ -352,7 +352,7 @@ static int mlx5e_rq_alloc_mpwqe_info(struct mlx5e_rq *rq,
 {
        int wq_sz = mlx5_wq_ll_get_size(&rq->mpwqe.wq);
 
-       rq->mpwqe.info = kzalloc_node(wq_sz * sizeof(*rq->mpwqe.info),
+       rq->mpwqe.info = kcalloc_node(wq_sz, sizeof(*rq->mpwqe.info),
                                      GFP_KERNEL, cpu_to_node(c->cpu));
        if (!rq->mpwqe.info)
                return -ENOMEM;
@@ -972,7 +972,7 @@ static int mlx5e_alloc_xdpsq_db(struct mlx5e_xdpsq *sq, int numa)
 {
        int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
 
-       sq->db.di = kzalloc_node(sizeof(*sq->db.di) * wq_sz,
+       sq->db.di = kcalloc_node(wq_sz, sizeof(*sq->db.di),
                                     GFP_KERNEL, numa);
        if (!sq->db.di) {
                mlx5e_free_xdpsq_db(sq);
@@ -1031,7 +1031,7 @@ static int mlx5e_alloc_icosq_db(struct mlx5e_icosq *sq, int numa)
 {
        u8 wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
 
-       sq->db.ico_wqe = kzalloc_node(sizeof(*sq->db.ico_wqe) * wq_sz,
+       sq->db.ico_wqe = kcalloc_node(wq_sz, sizeof(*sq->db.ico_wqe),
                                      GFP_KERNEL, numa);
        if (!sq->db.ico_wqe)
                return -ENOMEM;
@@ -1086,9 +1086,9 @@ static int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa)
        int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
        int df_sz = wq_sz * MLX5_SEND_WQEBB_NUM_DS;
 
-       sq->db.dma_fifo = kzalloc_node(df_sz * sizeof(*sq->db.dma_fifo),
+       sq->db.dma_fifo = kcalloc_node(df_sz, sizeof(*sq->db.dma_fifo),
                                           GFP_KERNEL, numa);
-       sq->db.wqe_info = kzalloc_node(wq_sz * sizeof(*sq->db.wqe_info),
+       sq->db.wqe_info = kcalloc_node(wq_sz, sizeof(*sq->db.wqe_info),
                                           GFP_KERNEL, numa);
        if (!sq->db.dma_fifo || !sq->db.wqe_info) {
                mlx5e_free_txqsq_db(sq);
index 3cfa468762393dd058d4699e57bf97020ab8400f..efb214fc545a231514ac1309033beb9579c6014a 100644 (file)
@@ -592,12 +592,12 @@ static int ndev_init_isr(struct amd_ntb_dev *ndev,
        ndev->db_mask = ndev->db_valid_mask;
 
        /* Try to set up msix irq */
-       ndev->vec = kzalloc_node(msix_max * sizeof(*ndev->vec),
+       ndev->vec = kcalloc_node(msix_max, sizeof(*ndev->vec),
                                 GFP_KERNEL, node);
        if (!ndev->vec)
                goto err_msix_vec_alloc;
 
-       ndev->msix = kzalloc_node(msix_max * sizeof(*ndev->msix),
+       ndev->msix = kcalloc_node(msix_max, sizeof(*ndev->msix),
                                  GFP_KERNEL, node);
        if (!ndev->msix)
                goto err_msix_alloc;
index 156b45cd4a198b9d1f1b50bebc33f4384953e89c..3be323132896fc29d5d5521d578997cc09082625 100644 (file)
@@ -448,12 +448,12 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev,
 
        /* Try to set up msix irq */
 
-       ndev->vec = kzalloc_node(msix_max * sizeof(*ndev->vec),
+       ndev->vec = kcalloc_node(msix_max, sizeof(*ndev->vec),
                                 GFP_KERNEL, node);
        if (!ndev->vec)
                goto err_msix_vec_alloc;
 
-       ndev->msix = kzalloc_node(msix_max * sizeof(*ndev->msix),
+       ndev->msix = kcalloc_node(msix_max, sizeof(*ndev->msix),
                                  GFP_KERNEL, node);
        if (!ndev->msix)
                goto err_msix_alloc;
index 9878c48826e3ee5889b6b1b38024db580a3b848a..504bdcc57ae843cc24ea909911b69d81772e485b 100644 (file)
@@ -1102,7 +1102,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
        max_mw_count_for_spads = (spad_count - MW0_SZ_HIGH) / 2;
        nt->mw_count = min(mw_count, max_mw_count_for_spads);
 
-       nt->mw_vec = kzalloc_node(mw_count * sizeof(*nt->mw_vec),
+       nt->mw_vec = kcalloc_node(mw_count, sizeof(*nt->mw_vec),
                                  GFP_KERNEL, node);
        if (!nt->mw_vec) {
                rc = -ENOMEM;
@@ -1143,7 +1143,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
        nt->qp_bitmap = qp_bitmap;
        nt->qp_bitmap_free = qp_bitmap;
 
-       nt->qp_vec = kzalloc_node(qp_count * sizeof(*nt->qp_vec),
+       nt->qp_vec = kcalloc_node(qp_count, sizeof(*nt->qp_vec),
                                  GFP_KERNEL, node);
        if (!nt->qp_vec) {
                rc = -ENOMEM;
index 323e3dc4bc591622b293a70ceee49b5084f93418..76da8c3a6f097e21a75fda283acd3971791f9a5b 100644 (file)
@@ -494,7 +494,7 @@ out_free:
 static inline unsigned long *
 sd_zbc_alloc_zone_bitmap(u32 nr_zones, int numa_node)
 {
-       return kzalloc_node(BITS_TO_LONGS(nr_zones) * sizeof(unsigned long),
+       return kcalloc_node(BITS_TO_LONGS(nr_zones), sizeof(unsigned long),
                            GFP_KERNEL, numa_node);
 }
 
index 4fe74711938e2efe0e8ef105e03ee02cc1c9f503..acbd3d7b8828693f79a51f19ad70fb1aa4ade050 100644 (file)
@@ -2274,8 +2274,8 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
                xhci->hw_ports[i].hw_portnum = i;
        }
 
-       xhci->rh_bw = kzalloc_node(sizeof(*xhci->rh_bw)*num_ports, flags,
-                       dev_to_node(dev));
+       xhci->rh_bw = kcalloc_node(num_ports, sizeof(*xhci->rh_bw), flags,
+                                  dev_to_node(dev));
        if (!xhci->rh_bw)
                return -ENOMEM;
        for (i = 0; i < num_ports; i++) {
index 1d8ca9ea997975e99af8aa5c73fd831dca0a22b4..045a37e9ddee3255fac6ab34b80682f4e2e968e1 100644 (file)
@@ -614,7 +614,8 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
                }
        }
 
-       rb->aux_pages = kzalloc_node(nr_pages * sizeof(void *), GFP_KERNEL, node);
+       rb->aux_pages = kcalloc_node(nr_pages, sizeof(void *), GFP_KERNEL,
+                                    node);
        if (!rb->aux_pages)
                return -ENOMEM;
 
index 6fdc6267f4a82ebc732ee049d41d1ecd5a39030d..fdd1b8aa8ac63c99f5165e4795043e653b821f7a 100644 (file)
@@ -52,7 +52,7 @@ int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift,
                return 0;
        }
 
-       sb->map = kzalloc_node(sb->map_nr * sizeof(*sb->map), flags, node);
+       sb->map = kcalloc_node(sb->map_nr, sizeof(*sb->map), flags, node);
        if (!sb->map)
                return -ENOMEM;