Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752925AbdCHMoq (ORCPT ); Wed, 8 Mar 2017 07:44:46 -0500 Received: from mout.web.de ([212.227.15.3]:57355 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752795AbdCHMop (ORCPT ); Wed, 8 Mar 2017 07:44:45 -0500 Subject: [PATCH 02/26] IB/ocrdma: Use kcalloc() in ocrdma_mbx_alloc_pd_range() To: linux-rdma@vger.kernel.org, Devesh Sharma , Doug Ledford , Hal Rosenstock , Sean Hefty , Selvin Xavier References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <7abcae42-6bc2-0653-69ea-5112943ff72e@users.sourceforge.net> Date: Wed, 8 Mar 2017 13:41:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:Z+JUdolhHGrlWRAPokLkKYshPD5fA+eEygU1NXdU+Hhsfw5vJcn Pl6+kljQwoFtT4qPRutJVoBwVq+vg/cNaC7TSKynnj/7tdxNLLqrveEgV/hZyFtc+RJH5Bn JKEcbO3ApwbmgF1X3TxE8cy7orpy6Yv/jjOTlHNN4t/fosc+dxZPshA3suAzKcoRvcOzUH2 1cVeJTEOdLW2JfcQM5QOQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:tA338Z7cBqc=:lgpny4TfqIZPtYIVqzIr/K lxLUvNmeTAZhww9t1/cR4xv2FtTLmtZiUvILqIQKia5tZ1cvCM5qr853lxA99O8m4NOSywmb5 ZSiROrAxXYuIyWM6uqQHsy08JU7DPyWVVYHSAqeOrZ3vwGLg+4DuKMP2TdU4IwCr77K/yx6Uq FZk2ZtDgDIJ8sN9aPqYhvI9DBumNZO/SMFoHwpiFsMFzUIW9xhvwgmCNhs8X2JPRYbBc5X+Bs GXTkVlhOJ3Sk1Ep4vEmj58h0NeQVt/B9jkhjq+/cyHTDY0R+0P65GPC5OLvAOlNf2+qqX3eiN AnVjw7na16J4sqhFjD8Xfmq069Yojocl2oW72GcHhZjsvNGRFq2Ei7O48suistYvtPLaEzde5 A2m4v4Dh3usmPGQ/DAAFwQxyAHFWzV3Fh/zHDKr6DHJYwM3tcwOdeyxsPNFjPVUDNqvHNUUj4 bmLa9Eymd0HIGw2vRedy4hjMpVS0UHF7/IEpaL8I9VU0xfExQ8+rp8fM3J4qgvjKUJaW5nU1p uPNlW2hQ1nZ6ieNgaaeHbo26GJS1JjBKxkycTtieEuoc/DpQA6vGMyuD/k8zVGtOPNVeMrx0D AsMAh4eBseJsJ/OYW8t7Vj2fG1dIi6nIlHCGmoIyDPzKGYgfXge9amKb1As82uaOxPo5OYK8m h6P2G6bYCK5AMtFrKVaADmgS8AVuzLK+jUMlO4uL59ipWv9dj1yE3F2v30GZpJyUYvtThHcyr VfvkGauYDmKev9v4k7NX43pCB1RqugWubbXTwCwi/zn50bV+R3T/Z5GC+QgAIpfhOhBAJU/uk bQNWIrI Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2179 Lines: 60 From: Markus Elfring Date: Tue, 7 Mar 2017 18:23:54 +0100 * 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 --- 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 cbac41b15d94..d5a3127b6df8 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); -- 2.12.0