From patchwork Thu Feb 16 09:04:35 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: 9576681 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 E5B0A60244 for ; Thu, 16 Feb 2017 09:05:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8E602848E for ; Thu, 16 Feb 2017 09:05:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CCAB9285B1; Thu, 16 Feb 2017 09:05:03 +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 C5D772848E for ; Thu, 16 Feb 2017 09:05:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752363AbdBPJE7 (ORCPT ); Thu, 16 Feb 2017 04:04:59 -0500 Received: from mout.web.de ([212.227.17.11]:55389 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751583AbdBPJEz (ORCPT ); Thu, 16 Feb 2017 04:04:55 -0500 Received: from [192.168.1.2] ([77.181.106.122]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MHp8z-1cf6nz1885-003cfW; Thu, 16 Feb 2017 10:04:38 +0100 Subject: [PATCH 2/2] IB/hns: Use kcalloc() in hns_roce_buddy_init() To: linux-rdma@vger.kernel.org, Doug Ledford , Hal Rosenstock , Sean Hefty , Wei Hu References: <4863af1d-ca80-1818-213e-7eadda35e8a1@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Thu, 16 Feb 2017 10:04:35 +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: <4863af1d-ca80-1818-213e-7eadda35e8a1@users.sourceforge.net> X-Provags-ID: V03:K0:79Kt2DGpmnMWyLxKSvFXMt0jPEV0D1syGffm3IRhFDJ+ZPMGn3H shOseggeiBN3jvCRBbJxK8PBg4As7OAWSFxk5YXQY4A/Vh5Dm5eKdbyOsa9P5D1malEcoz0 26drAezfUQ3NNSmtaAuoyOt0s+Uroh2hc2DBpigRCSi++Wmg3LP01FcCmcLGrSPVRXiCJaz eALQM+0ClCuMWooTCWHTA== X-UI-Out-Filterresults: notjunk:1; V01:K0:RssUtImLMy0=:x/Ozc+4DzOkDwsxQVVdxDl 8FVbW0lqMah+GcDL+CQk2KzIaJNWNaFMFtYdJXtyTibbjHniJQ5keJGXRKRnuc4RgOqxeiG7G 2+gHPmSBSeXPR805t16/73h9Dm+hThy+d2Vt4+c1Vx2z34YFAu1b9GybZGy2HtjDb5og1V0ko K0Zg/Ichj5C5j6BPG8ewxiUUlh6R3ccyBFZR8IA42+rTUXPZ5GTO+6O9DR3LN8INHivCpoxRG zk7OHrIqn+MmSa877n+0Kc5F9/F8j8ULJtqVRbMAIBxPwWZ1iWRgDC8XjpPaAuvTNceVOkqXy q+Fk0IGFPHhjLwj8sYPWmNne9DqybmQHV46hpTk9js8F7CqAvQzxI65kKNRv1/b5YeYzxDrkl M9SCRRJ8oI5+Db6JVuUCyf6R+5d8ULxxKKAQI+fLje7Xd+/+2bfCv5MB5jKfcWkKgWi8JbmgG CmqjLlh+I/ua+cqdOPwvVqyHVD6LGVSKfLrCtKD/LB0Pc6oZDurd7JPUXKmYRUJ0OWDnnjrW2 u8DFj/Yn4eef163x4Z2efQlI+LfzJXHsFjVtDqIBIBSM+I3ea6gYGpqXZwKyp+SsKapsziAmM a9/NIh2iCFojqlTSciIGnlaXRrrFE2DhwRomer04WNBdWw/7+vXq/C593kAvlhWBpd9syWA1j upjjmR86HSDo+6xh3bniA/zh+o0sKjDEgHY9nzxWy8AqVeHOjq1afMYulhJvCffStd9s7wLJP +yhv+1P9FCGh/OpH4EX/Rdj3ksLGRNW2nZoL9KkWmG5YTpMXY6ptxdQzEswt9Yu/CgiBjqlOl Qq4mSLg 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: Thu, 16 Feb 2017 09:30:55 +0100 * 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 types by pointer dereferences to make the corresponding size determinations a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/infiniband/hw/hns/hns_roce_mr.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c index 4139abee3b54..b48693510727 100644 --- a/drivers/infiniband/hw/hns/hns_roce_mr.c +++ b/drivers/infiniband/hw/hns/hns_roce_mr.c @@ -127,11 +127,12 @@ static int hns_roce_buddy_init(struct hns_roce_buddy *buddy, int max_order) buddy->max_order = max_order; spin_lock_init(&buddy->lock); - - buddy->bits = kzalloc((buddy->max_order + 1) * sizeof(long *), - GFP_KERNEL); - buddy->num_free = kzalloc((buddy->max_order + 1) * sizeof(int *), - GFP_KERNEL); + buddy->bits = kcalloc(buddy->max_order + 1, + sizeof(*buddy->bits), + GFP_KERNEL); + buddy->num_free = kcalloc(buddy->max_order + 1, + sizeof(*buddy->num_free), + GFP_KERNEL); if (!buddy->bits || !buddy->num_free) goto err_out;