From: SF Markus Elfring Date: Sat, 18 Feb 2017 21:19:08 +0000 Subject: [PATCH 29/29] IB/mlx5: Use kmalloc_array() in create_srq_kernel() Message-Id: <8dfa1135-5691-caf7-84e9-b30419c69187@users.sourceforge.net> List-Id: References: <1935365a-bd7c-461e-6a84-0c5d3a501fff@users.sourceforge.net> In-Reply-To: <1935365a-bd7c-461e-6a84-0c5d3a501fff-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Doug Ledford , Hal Rosenstock , Leon Romanovsky , Matan Barak , Sean Hefty , Yishai Hadas Cc: LKML , kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org From: Markus Elfring Date: Sat, 18 Feb 2017 21:18:15 +0100 * A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. * Replace the specification of a data type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/infiniband/hw/mlx5/srq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c index 7cb145f9a6db..8ba1953177af 100644 --- a/drivers/infiniband/hw/mlx5/srq.c +++ b/drivers/infiniband/hw/mlx5/srq.c @@ -195,8 +195,9 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq, goto err_buf; } mlx5_fill_page_array(&srq->buf, in->pas); - - srq->wrid = kmalloc(srq->msrq.max * sizeof(u64), GFP_KERNEL); + srq->wrid = kmalloc_array(srq->msrq.max, + sizeof(*srq->wrid), + GFP_KERNEL); if (!srq->wrid) { err = -ENOMEM; goto err_in; -- 2.11.1