From patchwork Sat Apr 22 14:30:29 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: 9694393 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 CF1F7600CA for ; Sat, 22 Apr 2017 14:30:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4636201F5 for ; Sat, 22 Apr 2017 14:30:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7EC728622; Sat, 22 Apr 2017 14:30:52 +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 50804201F5 for ; Sat, 22 Apr 2017 14:30:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424285AbdDVOau (ORCPT ); Sat, 22 Apr 2017 10:30:50 -0400 Received: from mout.web.de ([212.227.15.14]:56734 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423675AbdDVOau (ORCPT ); Sat, 22 Apr 2017 10:30:50 -0400 Received: from [192.168.1.2] ([77.181.100.232]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MJCEk-1czBAI0eMM-002qEW; Sat, 22 Apr 2017 16:30:32 +0200 Subject: [PATCH v2 01/12] IB/ocrdma: Use kcalloc() in ocrdma_mbx_alloc_pd_range() From: SF Markus Elfring To: Devesh Sharma , Doug Ledford , Hal Rosenstock , Sean Hefty , Selvin Xavier , Yuval Shaia , linux-rdma@vger.kernel.org Cc: LKML , kernel-janitors@vger.kernel.org References: <1492720999.3041.18.camel@redhat.com> <86425035-7da8-d2b1-8544-d4f7540d50c6@users.sourceforge.net> Message-ID: <21442d70-e77b-8338-30f7-9c41d048a665@users.sourceforge.net> Date: Sat, 22 Apr 2017 16:30:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 MIME-Version: 1.0 In-Reply-To: <86425035-7da8-d2b1-8544-d4f7540d50c6@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:ZBqcQ6+IUJawqbCaK/t+1FjUmO9Rfm5ZKS3cqT0ViAjzTvVcXxd p9EFSbTBlvgh1Kg0ZZhc7lqeRBh/3TfqHIlvhxFvcntTlg4weCk2sI1Q5bAVEWayrJjKNMV vrcID4KLtpzWX19xA9tDrf342LiJd4eU1T+8Td2fL/H0OmY6+L5tNSPr2BVDYIgeRfoYX96 Y16Bu4D33wSqBxzj1Y82w== X-UI-Out-Filterresults: notjunk:1; V01:K0:H7q2ItC6xNw=:3kqEApLNhdRIXBs1XerA91 SxekN9lRyikiIS9Q7UVQdE2uhvKOIzzN0SaZPkUEKou1HvTfHiPPIzk2oWhzmEBNg1BvT4wst ZquLGoPHI9JkubK4ERevDOGOmHkpxhRg7jhT8EJdqkAMHW9mY6SmFsYc52pFtR7b4+S8mmwZV I77sdNBb8m35zxcBl0F3QlWRg5Gm+VimfdVNoCcnDoT53O8tS4KVOXFeXcqFgV2iJEPbcKsp2 pVauG3GcL08L2LgudcIKcGgdyPHFMB5OGPkYG8Yvfh7+TTJcrlx6US7S7r3g2rIslJMRjDoFu c+ohW2mAkmS5mLUJU8QdqQ6SNRrmdXGtk0pNfFQbC59/mRu8lpx8DbfHQ4LhzFZISJp8pos3Q YtSt+hxG15bJjk6NZDdArgLJsvEoBjP0e4n2BBbVoy+4SqfITTGCoct+yku6m8fQHFMDaD1Sp UUs3UlidmeZNNE2BR48EpDFRtpC8/UkUuKlbACRv5A4TulseWXcNTtzEuAjUc+YuX/JPvzyiB bY1gDmtt7Qu4vE242siB1eLvjzJP0gSa9DwInqb94wiZ0yI+IuIBFWLfJdW50fkLtvDGa2oAn n7KmiUWAnoHXFJqT08Qwqon0Kpawv1MQ4WRRFQByIoAa4b2gXjGENqGodtSVJ3TBdtutxfOFv 3bRy7yJvTUjO0Em/aiDDELm/NB07Jinewvhc7W+uV3WdU4Mt86LGXeP2ZVjdasTtrgqcs4O5o UVRsUM6N4gTKVsacH3N1pvE2aVBg/X2ncE0IR1cSzUwMwpq8wbpX9cu4i7roVXim+E8m3j67i vW7SlZp 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: Sat, 22 Apr 2017 11:33:25 +0200 * Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus reuse the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. * Delete the local variable "pd_bitmap_size" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring Acked-By: Devesh Sharma --- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c index aa6967197620..c868314222b9 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c @@ -1505,7 +1505,6 @@ int ocrdma_mbx_dealloc_pd(struct ocrdma_dev *dev, struct ocrdma_pd *pd) static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) { int status = -ENOMEM; - size_t pd_bitmap_size; struct ocrdma_alloc_pd_range *cmd; struct ocrdma_alloc_pd_range_rsp *rsp; @@ -1527,10 +1526,10 @@ static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) dev->pd_mgr->pd_dpp_start = rsp->dpp_page_pdid & OCRDMA_ALLOC_PD_RNG_RSP_START_PDID_MASK; dev->pd_mgr->max_dpp_pd = rsp->pd_count; - pd_bitmap_size = - BITS_TO_LONGS(rsp->pd_count) * sizeof(long); - dev->pd_mgr->pd_dpp_bitmap = kzalloc(pd_bitmap_size, - GFP_KERNEL); + dev->pd_mgr->pd_dpp_bitmap + = kcalloc(BITS_TO_LONGS(rsp->pd_count), + sizeof(long), + GFP_KERNEL); } kfree(cmd); } @@ -1546,9 +1545,10 @@ static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) dev->pd_mgr->pd_norm_start = rsp->dpp_page_pdid & OCRDMA_ALLOC_PD_RNG_RSP_START_PDID_MASK; dev->pd_mgr->max_normal_pd = rsp->pd_count; - pd_bitmap_size = BITS_TO_LONGS(rsp->pd_count) * sizeof(long); - dev->pd_mgr->pd_norm_bitmap = kzalloc(pd_bitmap_size, - GFP_KERNEL); + dev->pd_mgr->pd_norm_bitmap + = kcalloc(BITS_TO_LONGS(rsp->pd_count), + sizeof(long), + GFP_KERNEL); } kfree(cmd);