From patchwork Sat Feb 18 21:12:16 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: 9581299 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 849D4600F6 for ; Sat, 18 Feb 2017 21:12:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73EEA2867F for ; Sat, 18 Feb 2017 21:12:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6747F28779; Sat, 18 Feb 2017 21:12:36 +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 0C1742867F for ; Sat, 18 Feb 2017 21:12:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753952AbdBRVMe (ORCPT ); Sat, 18 Feb 2017 16:12:34 -0500 Received: from mout.web.de ([212.227.15.14]:57193 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753828AbdBRVMd (ORCPT ); Sat, 18 Feb 2017 16:12:33 -0500 Received: from [192.168.1.2] ([77.181.107.93]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LzbAA-1cJd8C0XII-014kYh; Sat, 18 Feb 2017 22:12:18 +0100 Subject: [PATCH 22/29] IB/mlx4: Use kmalloc_array() in alloc_proxy_bufs() 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:12:16 +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:mIwZpzhWRabTExHNqHFK1zuwjldnmSeCII9bsQpZnvCGhvclZv5 6q66QISCGexzqRmlVdfs5wEOjsjP5nuGV30z6nVikEMCM41G7EdnuvJBQ9fp0bF70eZ3Nnd +GbIWdelnqlohARhWs1k/0GX1KbT42HNU5mRtmk6HMlmj7v/beHOKxbE1nhOlZ/tK2ehIj0 EmFYOPEd9TGJsfSXbQhQg== X-UI-Out-Filterresults: notjunk:1; V01:K0:o+qjFLcEBNs=:9gSh6vfurLP1Tau4+RUV9k zmNpAYlC51E+3ovtpQ4cVkN5p0NLBearEm4Fu3tOqPYKsGJ5A0nHZjuTNUjoGbJ5fvZqdCHgx Lw/WfR4PjI0wRqVcNgrplYW942547kdrDCkBMzBtLI27vJQa8mGPwihYVVCedPq9bIt9Rgd28 FlodAd/mmiFOInBwseAErVBjj7QNtVRFW0zPGLNF9ilhZlcwnBPkqJgQNrhzsNRFXTs/DZRsY rt4gEmOA9BInuu1zCdX6pur9EhteU3dieMB6UaxcqjZvy3VwKU9kYQrjtNt/79YcwzCpXZhRT sCcweKEa+Z3poRS8eck1cd+kDwmWepGXBM5oQ0mzn4SwwQXyY8+qZ1myu2+qREKwmS/uOfkNk jEyYj7fzH4j290+QmBAQ/3dfNVTS3XFhL+mQKQ1J7UTLH4hgB8sYAKFCCBHRIkDsV4yJdCfxd 2+x0y+AwtfgOao4e7C5uqAMiVE4l7rQiNUE62yzENDSalzH7OphhiB8I+m+pcrHLlfbdisi+v 39iELyEiXnzC4HgABOEehieBPSYg7bR7DbJ1kjgyi5yxMuCw62ZZ1G03QaP30JeYndcOrusGv DE9xkNxMtAm2+7MCcc+XcUkRcoM3kutp/kh4cPDueIONtrRBsuSzzii5X+TLdE+pbb05STue3 qSv8CbuTmg35HBf5p4EObKTuQXMfQT84MWER5T7c1rUcI5o5AUS3YFhqkvD+YBxw+gIPo/w/E qxj1Gl32uDqPD3Tl7J2cW5101ujo0hR+JuNLA98kMaRFtQ+zbOw5mugUtcR5xj1/WKoN7reOn OOLCR0u 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 16:56:52 +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 structure 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 Reviewed-by: Majd Dibbiny --- drivers/infiniband/hw/mlx4/qp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c index 7d76f769233c..11fec4a8fae5 100644 --- a/drivers/infiniband/hw/mlx4/qp.c +++ b/drivers/infiniband/hw/mlx4/qp.c @@ -554,9 +554,9 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp) { int i; - qp->sqp_proxy_rcv = - kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt, - GFP_KERNEL); + qp->sqp_proxy_rcv = kmalloc_array(qp->rq.wqe_cnt, + sizeof(*qp->sqp_proxy_rcv), + GFP_KERNEL); if (!qp->sqp_proxy_rcv) return -ENOMEM; for (i = 0; i < qp->rq.wqe_cnt; i++) {