From patchwork Sat Feb 18 21:19:08 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: 9581321 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 49025600F6 for ; Sat, 18 Feb 2017 21:19:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37DCB28710 for ; Sat, 18 Feb 2017 21:19:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 29A2B2875D; Sat, 18 Feb 2017 21:19:25 +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 D7D1428710 for ; Sat, 18 Feb 2017 21:19:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753537AbdBRVTX (ORCPT ); Sat, 18 Feb 2017 16:19:23 -0500 Received: from mout.web.de ([212.227.15.4]:60778 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753357AbdBRVTW (ORCPT ); Sat, 18 Feb 2017 16:19:22 -0500 Received: from [192.168.1.2] ([77.181.107.93]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MKIti-1cgqpl3aIo-001jGz; Sat, 18 Feb 2017 22:19:11 +0100 Subject: [PATCH 29/29] IB/mlx5: Use kmalloc_array() in create_srq_kernel() 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: <8dfa1135-5691-caf7-84e9-b30419c69187@users.sourceforge.net> Date: Sat, 18 Feb 2017 22:19:08 +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:eHPBifSrJnNnGuZNIAIwGMaGmf4eT0VK/hwNMdh8CsByClvPDFP VgQNG34CgW8gJ3vG/UC9xai87/eX8ceXRE0F+aBGP8r+66x+vaBo1jyxpL57e4GQA1sQzgO o4QCZkwm4kNMZplVUiwTd3Hzhmn7f53MZJ/FKSq2gV+CIqYQe3BwOrUyZ9LHjSXCmURoQ65 w72pOJwKDTuEfLmiTvEoQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:SWU9AvXjV+c=:0g0lHrk9nYK8Fw/xCQctK3 nma78AKgHKYEDeRr+7BOtv5IJN7K9xykNpmSleZLVgfMqMO40Qg+K4dMpPRxkFbPwXfz5Wcrt 5pc5bxnZiZYwGXXsry7cxBs1cajFx4tzbdS2YGeFBE29xyl6iZD5bR0HW6BG/kYsSCPjHcrmP vhsDkT+1oFloanO5OoYmoh9+yP05r2EXh9X6Pl9gp29/DgEs8J6Cj96CcT1crpQ/Gcc1+uz9Q tDGRlZohBeO7PsDMascahrvVqEWLWLosIZ3Hz9Gn2ndqtguG3isNRAxbfa4j4hHQU2youWIHG wDpE1FGV03/HhTtGGYtafo1yA57BWfjmZQOP4kH5F2ygoZCWxv36jFfnQomILryOi3qgNgt4W wkNdQK2v7FCetLdULhgfdfwUCirVG6KVGCSyCVqzH8L/xWvRh0cYlGCgdnJL42tVc6P/ofgsU CBnI6K9o4n3DqtsL+vcoUruVMFhv4zuOKPIz5rYFw69SmK24m3XX7rvNGS+6A9qgZjx5bE2Or 6j85/BEpUmxkf4yBgBoqUz6cLETCVURi1B92dOvWWwo8zZ0rml5hBe0NyqdM4DfagM3lENRWD 9JRIW3nAveaU5Z/QsvnHDYFcAgAuajF8gSDiSUQD7W7eIJchfZ1S8tntgRVfMLkfVzBfAJdzl gNsmWigYjTua/7KBtg3eRrIOLKAfMH/7D1Rwm0xIAuDv2Ar4aE10LjtyqsryHjJn1LWvNHE/U GneIInIHWrsOOG0H/7bhm/xI3WDHSNxyTw6iG/EW3ZTSl3wllRX5DeYzFEkZHsMd6mtMYYFug joDaCbN 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 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;