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