From patchwork Mon Mar 6 17:41:40 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: 9607225 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 6F8B860414 for ; Mon, 6 Mar 2017 17:41:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39F8426220 for ; Mon, 6 Mar 2017 17:41:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D90727BE5; Mon, 6 Mar 2017 17:41:55 +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 CAF4D26220 for ; Mon, 6 Mar 2017 17:41:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753775AbdCFRly (ORCPT ); Mon, 6 Mar 2017 12:41:54 -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 S1753597AbdCFRlx (ORCPT ); Mon, 6 Mar 2017 12:41:53 -0500 Received: from [192.168.1.2] ([78.48.114.236]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MHp8z-1chM8e1y8r-003cnW; Mon, 06 Mar 2017 18:41:41 +0100 Subject: [PATCH 2/5] IB/nes: Use kcalloc() in nes_reg_user_mr() To: linux-rdma@vger.kernel.org, Doug Ledford , Faisal Latif , Hal Rosenstock , Sean Hefty References: <502a5a6f-ee91-dd2f-cdc7-63f396059529@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <192fcb99-eef6-8820-9260-b6ad0ee60165@users.sourceforge.net> Date: Mon, 6 Mar 2017 18:41:40 +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: <502a5a6f-ee91-dd2f-cdc7-63f396059529@users.sourceforge.net> X-Provags-ID: V03:K0:zrT1sppDRUtILFuoIVNoxUMhXZCaCF4OZNCwj9JVh6t16LltCRy ROidk45iUG1ynkTB/dOlCtNCFF21SJMhUR3N5t8yFwJdtSyCZ2NhSiq1MDrwG9hpDkqMeL6 9UlLVvf20/rof9YtjhtdiykHu+h7A5zkvPlJE2WRk1EyfStbQBfN2QHXMRWL0W74EOexmEl IiYkjCy77SEwtqIjc9QHA== X-UI-Out-Filterresults: notjunk:1; V01:K0:A1yP4ldLCPU=:OgrHcpIdJTAiB3Cw4nBly8 yfvqTazU2EN+P8X4ECbmVYPu9fKKYCZ+L2BiP/nL87ICoyBP3di3RaYlQeG8r9WcUvjbW/n2A KXMA1NHgmED2zAPa38UJnEdsVOaKhHgDgJoYw5bQXDyXsV8q5aI1N6ylq73mhZsb28pGU9imR Pth99XrbDGLFRdcu5HEWDr2wicU9Nos8KBn+W40w8eo+gQNnq3bLDtS2veQA7Gwi3xd9oFX8U sGeeUwDIqfbPeUmvL/wS2ofUH/s6k11MbeVk9Gk+xOedyVGKR886NWK6jCz0amqbeT4p3OHUl U3Be2QlN9juUjyLFJ8OX0sIErUW3Ao3f3NHcYt6Y068+FHXosEaNYOP+9bKArqhVqkGAyaeyA U8yz7fY85oIQ8+5qLfK1FdghNvBPuYVlOx3qD1MmmrWwFXnrUqLOD1mp+ItAKYxB3fG0TppiS WDx93OXMa5x9szhMkmrPEpIMcBR2mdb2NJUDLpue3qifHdn2eX3kAO6sAvaKyEt+LpBMS5aGN Ki+0jKJulHE6jNQRyjgyO9T34VemfIu796ybHYtglNI4tnuH+DxFNrvqenSk7QhQOxHgurzJH F2yyVGyZAc9jgUz+EZj4REf6f16m3LIQ2edRjP5Vbxo59ebzIPUlAcQzicEU5lnTj5C0lpyg4 42tHqRP7hsiaAwGBR45+NIUnQclw4gS3Ucl3jlTROfYsW1zesZrHC5uuE+uZ0Oob3M72pxRwI Xl7oOTQQRgIOICwYQxxMJuOXM53h1x0BpgHlqGAb6Ltedvj6u+5lVfpqR/uPBFnhvi5d1Anz0 x63DGvx 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: Mon, 6 Mar 2017 16:26:25 +0100 A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus reuse the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/infiniband/hw/nes/nes_verbs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c index d3eae2f3e9f5..a28dfeaa1f45 100644 --- a/drivers/infiniband/hw/nes/nes_verbs.c +++ b/drivers/infiniband/hw/nes/nes_verbs.c @@ -2260,8 +2260,9 @@ static struct ib_mr *nes_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, ibmr = ERR_PTR(-ENOMEM); goto reg_user_mr_err; } - root_vpbl.leaf_vpbl = kzalloc(sizeof(*root_vpbl.leaf_vpbl)*1024, - GFP_KERNEL); + root_vpbl.leaf_vpbl = kcalloc(1024, + sizeof(*root_vpbl.leaf_vpbl), + GFP_KERNEL); if (!root_vpbl.leaf_vpbl) { ib_umem_release(region); pci_free_consistent(nesdev->pcidev, 8192, root_vpbl.pbl_vbase,