Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932258AbdDENx5 (ORCPT ); Wed, 5 Apr 2017 09:53:57 -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 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-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1671 Lines: 42 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 --- 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; -- 2.12.2