From patchwork Wed Apr 5 13:52:48 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: 9664151 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 42B5B602B8 for ; Wed, 5 Apr 2017 13:55:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 323AB2853E for ; Wed, 5 Apr 2017 13:55:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 271C128548; Wed, 5 Apr 2017 13:55:34 +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 D01B22853E for ; Wed, 5 Apr 2017 13:55:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932072AbdDENx4 (ORCPT ); Wed, 5 Apr 2017 09:53:56 -0400 Received: from mout.web.de ([212.227.17.12]:49774 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754609AbdDENw7 (ORCPT ); Wed, 5 Apr 2017 09:52:59 -0400 Received: from [192.168.1.2] ([77.182.172.209]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LqDYi-1cQoG92STg-00dq7Z; Wed, 05 Apr 2017 15:52:49 +0200 Subject: [PATCH 2/5] IB/qib: Use kmalloc_array() in qib_init_7322_variables() From: SF Markus Elfring To: linux-rdma@vger.kernel.org, Doug Ledford , Hal Rosenstock , Mike Marciniszyn , Sean Hefty Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <894a5d6c-882c-0bd9-f3ec-80fc8b7c355c@users.sourceforge.net> Date: Wed, 5 Apr 2017 15:52:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-Provags-ID: V03:K0:RLsEuDMMrXhEdbS061aRuBm3dcfoJpPe97QHbX/0o0uxdXqmoMx SBiNf3FbQOWN7fwQzsWMC2WDTcoWEfEW6saBZVxMPu2fPZLA+yf+eZTgMN+9o71qK3Tvlzz +PkPjVizEWm2emmwfhyEUz6+uyoZpqe0YqcevcNAd7JY/cwZ0LS/l2BEi+B+lXkQlXw5WxS uP5D67OSdxBngUFBGFAeg== X-UI-Out-Filterresults: notjunk:1; V01:K0:F1XiKNgVRhU=:PXGvN1fgZkc5VSIVp7/mcP 2qIotf1jSZCXRbEY79OdujP6/fl/4BMW4Kk3fELpRcfF3dreSu/vxQE97JL/m7afjBuZHuRWa 7/blmdANH29HRQHlG1AidMqUN3LIJkvRKgleymYcaUcyzEBhj1j79htuppo0zZh2AGjdjMvuX 0qPLRORZR0tnlinyMGZntKRQDKGaiFR8pDescXxtzItXtH0tBxDBg1HCEu69OIm0nm/7qjPxh OgnN8zgilzK8sU3+5FoaHmbgKjwpZBxkPRTxNH65K5TsK7sdSLLrF0pzl0gf8RnVE3cZZUIYv E9ph8DAYssKjD+UDmegAHr4HOkore9BH7aD4W6MOIHsIM+7Ec+mTvdQLBHyw7COZXZsmJi+ga k+5YNX7IhZjwQM0SHk2xjJ3OS/v2BRuMN8pD3gSzhnt2vHaP6gxo1UM2GHqll9BfsRggUjv/q Ijfn+SiQjfwCVh8JYw2q681lrck/3IeygAUWVXvAKulvZP74Rqx42ZPP2rUsl4FRW0Jli1Xj+ j2InWN6jNOLWhAgS4neG60fX7oitvuW8Mm/TCtFZPtqkZOAngrgFzG5u/JEI1hZo6qtGSyQA1 39D4m6hsOVEFSWVcUOilmgKBirLhEwE1gJuXL8ZrW/tktmyXOSaR1DCeyMISNr5dQK6Rk47Tb ioeClZfDzfmylyj6zexrohGaDchV2SUCIZuQQCmGzVT2DhRlmsJXTTplgBVxjMbbTfo02uk0Z ouULthVVJyKE9XJoRUEGcLrpDqtR7A2OvMZxM+SalG/S+ucAsfkluSlqynz+aLmT6JRymPiN+ 5dBW3m+ 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: Wed, 5 Apr 2017 09:51:33 +0200 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 Reviewed-by: Yuval Shaia --- drivers/infiniband/hw/qib/qib_iba7322.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c index e4e4e675c89c..490f432809b8 100644 --- a/drivers/infiniband/hw/qib/qib_iba7322.c +++ b/drivers/infiniband/hw/qib/qib_iba7322.c @@ -6442,12 +6442,15 @@ static int qib_init_7322_variables(struct qib_devdata *dd) sbufcnt = dd->piobcnt2k + dd->piobcnt4k + NUM_VL15_BUFS + BITS_PER_LONG - 1; sbufcnt /= BITS_PER_LONG; - dd->cspec->sendchkenable = kmalloc(sbufcnt * - sizeof(*dd->cspec->sendchkenable), GFP_KERNEL); - dd->cspec->sendgrhchk = kmalloc(sbufcnt * - sizeof(*dd->cspec->sendgrhchk), GFP_KERNEL); - dd->cspec->sendibchk = kmalloc(sbufcnt * - sizeof(*dd->cspec->sendibchk), GFP_KERNEL); + dd->cspec->sendchkenable = kmalloc_array(sbufcnt, + sizeof(*dd->cspec->sendchkenable), + GFP_KERNEL); + dd->cspec->sendgrhchk = kmalloc_array(sbufcnt, + sizeof(*dd->cspec->sendgrhchk), + GFP_KERNEL); + dd->cspec->sendibchk = kmalloc_array(sbufcnt, + sizeof(*dd->cspec->sendibchk), + GFP_KERNEL); if (!dd->cspec->sendchkenable || !dd->cspec->sendgrhchk || !dd->cspec->sendibchk) { ret = -ENOMEM;