From patchwork Wed Apr 5 13:54:45 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: 9664147 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 1F079602B8 for ; Wed, 5 Apr 2017 13:55:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C2C328535 for ; Wed, 5 Apr 2017 13:55:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0088C28545; Wed, 5 Apr 2017 13:55:11 +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 9E21128535 for ; Wed, 5 Apr 2017 13:55:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932182AbdDENzI (ORCPT ); Wed, 5 Apr 2017 09:55:08 -0400 Received: from mout.web.de ([217.72.192.78]:60066 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932562AbdDENzC (ORCPT ); Wed, 5 Apr 2017 09:55:02 -0400 Received: from [192.168.1.2] ([77.182.172.209]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0M9ojk-1cp8cJ1XZo-00B6lI; Wed, 05 Apr 2017 15:54:47 +0200 Subject: [PATCH 4/5] IB/qib: Use kcalloc() in qib_init_pportdata() 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: Date: Wed, 5 Apr 2017 15:54:45 +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:9bbLQ1FjCCx4vIlT+lOMFtZawZtAfg9S4yrrfTH5bzzs2xvIs78 jnufx2PJQU42lOE03Uubif9Owz20OHVTRSedfIBeb4OHJZDJbzcN84ZXEObmzj7v/N5L/1/ Km+7w/d61T4ZFbD4ynxevKEGyn2x737CdxLLXbWvvpWAcboFgFZgCY84+oR0eFLwvsgtMua ZEOL07pnA7sJbmXtZiBLg== X-UI-Out-Filterresults: notjunk:1; V01:K0:8YgxAHeVZfI=:wIosYwvqDGlTMi+pgTkPdY eILBgvAJkYFmTJAjwbj7MpGJ/fAJn65gCPGg2nbJMVdzlIMs2pl8HaznD2pfkQXIzLBzllo89 /xts3YXmbl26bNJ4rzFpoL+LQFFPQpbymIKdB8+Tj65jSQCSPSMurER66OwvyvF2Ex3T8zSnM NfEqLozdMW+q45BoMysABSx7NoZkmvPCHHtQfkn5fUm9DC+bC9R85Cn0JtWiycTkXROzBqSkV X7xqp4Ykn2BOykiWSZRJocBeilKIl6+/0wn7dBeus71+ls5rWLF2vDf/WeuJHdwHaNfAY43V2 RDwzmpkcZlnC9ZkoFtp/DQMtk7aqjv36tOIpo2ew93hTWpPil46/XhrH+uRmxcUHUCtGxoGST yxbKg3o9/ynvgzCi0WxJdfAEiQP3qFzhA5qvhOEcnNoYzwj8buYx5KZeh3tlpLcaUF6ss4kVt 92eS9TYvnHTzW9gKa8Jv/BAkUsn5J0kF1i5hHe3KhIs/yCgWR2OADooefzPd8KYNQ7YH9PCeE dfWgKTsQGejqDe/p70yjVxMXtNhj9504/SQKVUZFJw34UmRClcrbCap0igJsLEKWMvhgET7qf g7VRwmpcRFxoEwS+AjLxqg6dABh+72tcnPdV/xA+gxn8pUfJ8M9LA8TzMK2dB2Q6M2yhnvLhl np6Dz7DO/yvCpt9E9yukWP1PqZ+fuY2fRHyYotYdTXaXVgfjgKP4tY7VaAli8AJkq6t9oe/pP PaIiNA85JHUwHEDiyefH9lAbJN/fMt/1iTn2sRc0C3SSGETwa2JP24z5SZ+3lwRyG6Dzba77a 7JQhDeb 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 14:20:10 +0200 * Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. * Replace the specification of data structures by pointer dereferences to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/infiniband/hw/qib/qib_init.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c index 9e680ca971e3..101580f0460a 100644 --- a/drivers/infiniband/hw/qib/qib_init.c +++ b/drivers/infiniband/hw/qib/qib_init.c @@ -258,15 +258,15 @@ int qib_init_pportdata(struct qib_pportdata *ppd, struct qib_devdata *dd, ppd->cc_max_table_entries = ppd->cc_supported_table_entries/IB_CCT_ENTRIES; - - size = IB_CC_TABLE_CAP_DEFAULT * sizeof(struct ib_cc_table_entry) - * IB_CCT_ENTRIES; - ppd->ccti_entries = kzalloc(size, GFP_KERNEL); + ppd->ccti_entries = kcalloc(IB_CC_TABLE_CAP_DEFAULT * IB_CCT_ENTRIES, + sizeof(*ppd->ccti_entries), + GFP_KERNEL); if (!ppd->ccti_entries) goto bail; - size = IB_CC_CCS_ENTRIES * sizeof(struct ib_cc_congestion_entry); - ppd->congestion_entries = kzalloc(size, GFP_KERNEL); + ppd->congestion_entries = kcalloc(IB_CC_CCS_ENTRIES, + sizeof(*ppd->congestion_entries), + GFP_KERNEL); if (!ppd->congestion_entries) goto bail_1;