From patchwork Sat Feb 18 21:17:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9581313 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BBB1A600F6 for ; Sat, 18 Feb 2017 21:17:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9E7028710 for ; Sat, 18 Feb 2017 21:17:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9ACE22875D; Sat, 18 Feb 2017 21:17:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C54528710 for ; Sat, 18 Feb 2017 21:17:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753492AbdBRVR4 (ORCPT ); Sat, 18 Feb 2017 16:17:56 -0500 Received: from mout.web.de ([212.227.15.4]:61195 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753315AbdBRVRz (ORCPT ); Sat, 18 Feb 2017 16:17:55 -0500 Received: from [192.168.1.2] ([77.181.107.93]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LwI2w-1cIWjO0jgU-0186ID; Sat, 18 Feb 2017 22:17:04 +0100 Subject: [PATCH 27/29] IB/mlx5: Use kmalloc_array() in create_kernel_qp() To: linux-rdma@vger.kernel.org, Doug Ledford , Hal Rosenstock , Leon Romanovsky , Matan Barak , Sean Hefty , Yishai Hadas References: <1935365a-bd7c-461e-6a84-0c5d3a501fff@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Sat, 18 Feb 2017 22:17:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <1935365a-bd7c-461e-6a84-0c5d3a501fff@users.sourceforge.net> X-Provags-ID: V03:K0:7nv4sy2EGI68k2BeVufLk9y1OExGGpAwRzQ1tehzaa8IjLlu4Sq ZSU98SghHdOt4I9rmbQYEAs0+0QIiH6hDB1hO6OsyYQVjT38cp7qJnvFfvzo2Q+g0i7ISxt fU3MAh3DvJnrRIZ7WppZkHdMnJ1mn4RFNqamcuoLXhUMkGejRNyeQK8oMc+UwYu9OKz0uo0 76Cyxu3wQxqH3msNMeqOg== X-UI-Out-Filterresults: notjunk:1; V01:K0:LRrbbUZMMtc=:k+dokZ9WkGbR9Wl9tzCPDO b5EjEF7QoPmCBdPySjC+80mB15tMsqnHxy9Ju85x+Wl5E997Kk5a4jTEoZDxEdQpBeAqA2nfz YGD0oegxQ9XNjUSnVPqsoPVjWuh58D33SM8AmneKi8POM7N4191lzhnHk7yt2Sr53j6JcsIfS DDnnKyWCWkyjvdaS6yXj8mM7Ax5/TloqiCWULg/zq9zj9n21YzcI3Uxuw6b2wDWEc7Ze8jUkR zHhwwr5G95BvELt+gc3OPqc14PpdjD6nGAUk5RULcinAZ6hMabJj1n4cFAxL0S1AyYcFjQDqa fepm1/NkMfwuzEM+txOSSaJ6C6ni1LnIaksqjYn2uS0zmP00tJKK9Q1mFGOFNSVBbGMlAD3qr ZCFjFd0OZjdeJ05OCFWoHM7C95fER5maRBPzP4AqTo/8p6AID4gxch0BagQoCa7kapRivY8b2 WZrLKrKPS10yeTD4tynleic599O8z3pMjVDG1ZBPECecp+Xoln2eu+j7C0lN54GXvipvqrbYy 327ssm6fSjZOfr/ZvgbkmxjfNs0zVybUy9RfX4OWFfs8qcr8mMQfm/BHtVGHrhAApJoUDEa8/ rVEEav0AbalakaYShovBQOFHBW5SkoZu/3TqmsmR7h4XG4b4ibpjtviOKBpsLxOVeqi21e5lD xYyMthozag8lcvK8mcS44BHe+kdMS7jxYGoIXhdvM6xU2GJIMyoEbLjcG8KD+co4FpuyYUe0t 4FyZ+ar0TbD4YFBr+ARbKzr4stAYxyXqzTTwtS9JYgm7PFGzbT+wz6s/TjS4e3nAGX5x5SVk4 OCDkD9+ Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sat, 18 Feb 2017 20:12:44 +0100 Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/infiniband/hw/mlx5/qp.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index 5ed5208d0ddd..e6e9b468b206 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c @@ -955,12 +955,21 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev, goto err_free; } - qp->sq.wrid = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wrid), GFP_KERNEL); - qp->sq.wr_data = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wr_data), GFP_KERNEL); - qp->rq.wrid = kmalloc(qp->rq.wqe_cnt * sizeof(*qp->rq.wrid), GFP_KERNEL); - qp->sq.w_list = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.w_list), GFP_KERNEL); - qp->sq.wqe_head = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head), GFP_KERNEL); - + qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt, + sizeof(*qp->sq.wrid), + GFP_KERNEL); + qp->sq.wr_data = kmalloc_array(qp->sq.wqe_cnt, + sizeof(*qp->sq.wr_data), + GFP_KERNEL); + qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt, + sizeof(*qp->rq.wrid), + GFP_KERNEL); + qp->sq.w_list = kmalloc_array(qp->sq.wqe_cnt, + sizeof(*qp->sq.w_list), + GFP_KERNEL); + qp->sq.wqe_head = kmalloc_array(qp->sq.wqe_cnt, + sizeof(*qp->sq.wqe_head), + GFP_KERNEL); if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid || !qp->sq.w_list || !qp->sq.wqe_head) { err = -ENOMEM;