From: Leon Romanovsky <leonro@xxxxxxxxxxxx> Replace general allocations to be zero based. Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- drivers/infiniband/hw/mlx5/cq.c | 2 +- drivers/infiniband/hw/mlx5/doorbell.c | 2 +- drivers/infiniband/hw/mlx5/mad.c | 18 +++++++++--------- drivers/infiniband/hw/mlx5/main.c | 10 +++++----- drivers/infiniband/hw/mlx5/qp.c | 12 ++++++------ drivers/infiniband/hw/mlx5/srq.c | 4 ++-- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c index 94a27d89a303..c23d3e30c490 100644 --- a/drivers/infiniband/hw/mlx5/cq.c +++ b/drivers/infiniband/hw/mlx5/cq.c @@ -1452,7 +1452,7 @@ int mlx5_ib_generate_wc(struct ib_cq *ibcq, struct ib_wc *wc) struct mlx5_ib_cq *cq = to_mcq(ibcq); unsigned long flags; - soft_wc = kmalloc(sizeof(*soft_wc), GFP_ATOMIC); + soft_wc = kzalloc(sizeof(*soft_wc), GFP_ATOMIC); if (!soft_wc) return -ENOMEM; diff --git a/drivers/infiniband/hw/mlx5/doorbell.c b/drivers/infiniband/hw/mlx5/doorbell.c index a0e4e6ddb71a..e7e52be0819b 100644 --- a/drivers/infiniband/hw/mlx5/doorbell.c +++ b/drivers/infiniband/hw/mlx5/doorbell.c @@ -55,7 +55,7 @@ int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, unsigned long virt, if (page->user_virt == (virt & PAGE_MASK)) goto found; - page = kmalloc(sizeof(*page), GFP_KERNEL); + page = kzalloc(sizeof(*page), GFP_KERNEL); if (!page) { err = -ENOMEM; goto out; diff --git a/drivers/infiniband/hw/mlx5/mad.c b/drivers/infiniband/hw/mlx5/mad.c index 32a9e9228b13..ca29576d3863 100644 --- a/drivers/infiniband/hw/mlx5/mad.c +++ b/drivers/infiniband/hw/mlx5/mad.c @@ -290,7 +290,7 @@ int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, u8 port) u16 packet_error; in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL); - out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); + out_mad = kzalloc(sizeof(*out_mad), GFP_KERNEL); if (!in_mad || !out_mad) goto out; @@ -337,7 +337,7 @@ int mlx5_query_mad_ifc_system_image_guid(struct ib_device *ibdev, struct ib_smp *out_mad = NULL; int err = -ENOMEM; - out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); + out_mad = kzalloc(sizeof(*out_mad), GFP_KERNEL); if (!out_mad) return -ENOMEM; @@ -359,7 +359,7 @@ int mlx5_query_mad_ifc_max_pkeys(struct ib_device *ibdev, struct ib_smp *out_mad = NULL; int err = -ENOMEM; - out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); + out_mad = kzalloc(sizeof(*out_mad), GFP_KERNEL); if (!out_mad) return -ENOMEM; @@ -381,7 +381,7 @@ int mlx5_query_mad_ifc_vendor_id(struct ib_device *ibdev, struct ib_smp *out_mad = NULL; int err = -ENOMEM; - out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); + out_mad = kzalloc(sizeof(*out_mad), GFP_KERNEL); if (!out_mad) return -ENOMEM; @@ -404,7 +404,7 @@ int mlx5_query_mad_ifc_node_desc(struct mlx5_ib_dev *dev, char *node_desc) int err = -ENOMEM; in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL); - out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); + out_mad = kzalloc(sizeof(*out_mad), GFP_KERNEL); if (!in_mad || !out_mad) goto out; @@ -429,7 +429,7 @@ int mlx5_query_mad_ifc_node_guid(struct mlx5_ib_dev *dev, __be64 *node_guid) int err = -ENOMEM; in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL); - out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); + out_mad = kzalloc(sizeof(*out_mad), GFP_KERNEL); if (!in_mad || !out_mad) goto out; @@ -455,7 +455,7 @@ int mlx5_query_mad_ifc_pkey(struct ib_device *ibdev, u8 port, u16 index, int err = -ENOMEM; in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL); - out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); + out_mad = kzalloc(sizeof(*out_mad), GFP_KERNEL); if (!in_mad || !out_mad) goto out; @@ -484,7 +484,7 @@ int mlx5_query_mad_ifc_gids(struct ib_device *ibdev, u8 port, int index, int err = -ENOMEM; in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL); - out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); + out_mad = kzalloc(sizeof(*out_mad), GFP_KERNEL); if (!in_mad || !out_mad) goto out; @@ -532,7 +532,7 @@ int mlx5_query_mad_ifc_port(struct ib_device *ibdev, u8 port, } in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL); - out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL); + out_mad = kzalloc(sizeof(*out_mad), GFP_KERNEL); if (!in_mad || !out_mad) goto out; diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index de44989c88ae..dcfd878bff28 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -2360,7 +2360,7 @@ static struct ib_pd *mlx5_ib_alloc_pd(struct ib_device *ibdev, struct mlx5_ib_pd *pd; int err; - pd = kmalloc(sizeof(*pd), GFP_KERNEL); + pd = kzalloc(sizeof(*pd), GFP_KERNEL); if (!pd) return ERR_PTR(-ENOMEM); @@ -3413,7 +3413,7 @@ mlx5_ib_create_flow_action_esp(struct ib_device *device, aes_gcm->iv_algo != IB_UVERBS_FLOW_ACTION_IV_ALGO_SEQ) return ERR_PTR(-EOPNOTSUPP); - action = kmalloc(sizeof(*action), GFP_KERNEL); + action = kzalloc(sizeof(*action), GFP_KERNEL); if (!action) return ERR_PTR(-ENOMEM); @@ -3798,7 +3798,7 @@ static void mlx5_ib_event(struct mlx5_core_dev *dev, void *context, { struct mlx5_ib_event_work *work; - work = kmalloc(sizeof(*work), GFP_ATOMIC); + work = kzalloc(sizeof(*work), GFP_ATOMIC); if (!work) return; @@ -3855,11 +3855,11 @@ static int get_port_caps(struct mlx5_ib_dev *dev, u8 port) int err = -ENOMEM; struct ib_udata uhw = {.inlen = 0, .outlen = 0}; - pprops = kmalloc(sizeof(*pprops), GFP_KERNEL); + pprops = kzalloc(sizeof(*pprops), GFP_KERNEL); if (!pprops) goto out; - dprops = kmalloc(sizeof(*dprops), GFP_KERNEL); + dprops = kzalloc(sizeof(*dprops), GFP_KERNEL); if (!dprops) goto out; diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index 0fd13e5d529a..7f6f65217341 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c @@ -999,15 +999,15 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev, } qp->sq.wrid = kvmalloc_array(qp->sq.wqe_cnt, - sizeof(*qp->sq.wrid), GFP_KERNEL); + sizeof(*qp->sq.wrid), GFP_KERNEL | __GFP_ZERO); qp->sq.wr_data = kvmalloc_array(qp->sq.wqe_cnt, - sizeof(*qp->sq.wr_data), GFP_KERNEL); + sizeof(*qp->sq.wr_data), GFP_KERNEL | __GFP_ZERO); qp->rq.wrid = kvmalloc_array(qp->rq.wqe_cnt, - sizeof(*qp->rq.wrid), GFP_KERNEL); + sizeof(*qp->rq.wrid), GFP_KERNEL | __GFP_ZERO); qp->sq.w_list = kvmalloc_array(qp->sq.wqe_cnt, - sizeof(*qp->sq.w_list), GFP_KERNEL); + sizeof(*qp->sq.w_list), GFP_KERNEL | __GFP_ZERO); qp->sq.wqe_head = kvmalloc_array(qp->sq.wqe_cnt, - sizeof(*qp->sq.wqe_head), GFP_KERNEL); + sizeof(*qp->sq.wqe_head), GFP_KERNEL | __GFP_ZERO); if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid || !qp->sq.w_list || !qp->sq.wqe_head) { @@ -5139,7 +5139,7 @@ struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev, if (!MLX5_CAP_GEN(dev->mdev, xrc)) return ERR_PTR(-ENOSYS); - xrcd = kmalloc(sizeof(*xrcd), GFP_KERNEL); + xrcd = kzalloc(sizeof(*xrcd), GFP_KERNEL); if (!xrcd) return ERR_PTR(-ENOMEM); diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c index 3c7522d025f2..76ce24a97b3a 100644 --- a/drivers/infiniband/hw/mlx5/srq.c +++ b/drivers/infiniband/hw/mlx5/srq.c @@ -196,7 +196,7 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq, } mlx5_fill_page_array(&srq->buf, in->pas); - srq->wrid = kvmalloc_array(srq->msrq.max, sizeof(u64), GFP_KERNEL); + srq->wrid = kvmalloc_array(srq->msrq.max, sizeof(u64), GFP_KERNEL | __GFP_ZERO); if (!srq->wrid) { err = -ENOMEM; goto err_in; @@ -255,7 +255,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, return ERR_PTR(-EINVAL); } - srq = kmalloc(sizeof(*srq), GFP_KERNEL); + srq = kzalloc(sizeof(*srq), GFP_KERNEL); if (!srq) return ERR_PTR(-ENOMEM); -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html