From patchwork Thu Apr 6 20:10:47 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: 9668353 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 4774760364 for ; Thu, 6 Apr 2017 20:11:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DF28285CB for ; Thu, 6 Apr 2017 20:11:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71528285D2; Thu, 6 Apr 2017 20:11:29 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 0C4D3285CB for ; Thu, 6 Apr 2017 20:11:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752296AbdDFULB (ORCPT ); Thu, 6 Apr 2017 16:11:01 -0400 Received: from mout.web.de ([212.227.15.14]:61210 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751180AbdDFUK7 (ORCPT ); Thu, 6 Apr 2017 16:10:59 -0400 Received: from [192.168.1.2] ([78.48.224.88]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0M6Dve-1cBQqh0dY2-00y6fR; Thu, 06 Apr 2017 22:10:49 +0200 Subject: [PATCH 2/2] IB/usnic: Use kcalloc() in usnic_vnic_alloc_res_chunk() From: SF Markus Elfring To: linux-rdma@vger.kernel.org, Christian Benvenuti , Dave Goodell , Doug Ledford , Hal Rosenstock , Sean Hefty Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <5d9ef1cc-44c5-b5a3-7ffd-3d94c517f129@users.sourceforge.net> Date: Thu, 6 Apr 2017 22:10:47 +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-Language: en-GB X-Provags-ID: V03:K0:hMnmo4T9DH4pHHSwkr1h1+rkMsPOSwssvv+JRa8hxVvlaZmpCyV JLnjrrji+3FlYGwn8tX18bFbL2yFyWu0u9ichyBdWYmmCpswjWKjhuuBLQSqRcp9jUSzScJ K5EduYt8SC1E3MgOK4XvwKC1l5+HOOrH+HuiLgN0N9nH8B97d5o9QsiIjsypvJpqaL2Jljh jXO/RIwPmU94Myrwi5wBw== X-UI-Out-Filterresults: notjunk:1; V01:K0:aNTjZJ7NeA0=:N6EWEVJn8vW4+guCqAz/Mu pjNScaDc6sOZknR+slJ4hJqtTjEnYAaiSZ6hUixXEDr/8wtkfNuGnxIMXDt+iI3F6E12mgbex CqfSHS8vaKsSr+uEseBtf9LCueg2v6qyA2n+eO1g6kbgByE3s/ouBUhMH8DVQRWUl+JjYg2fj tkgPwxyHa4r/wKUKGOwSe2MYOzfj40tihyQLrSuJknbUVQHOkUnkk+g9nYKxjZKaf8a6XGwum KQsctieo8Z1kvOUCQVaAX09LHnYFLYLg9cMPJwxhLdvb7xxPL0Ylm3JP7oYWll3bjeUNIeDxN U4hsSzbRhJ6ZZlWuQLPR89DEBBLQqtxgSM9X11zj+R/3nTCT44z00Lu1wKaYIHEVcaNzn54Ad 4zPEDNIdF6L90y+ZfZFAUJt6xEPYiOHB+986L3bUj6H5NJObhHZJ2C0kIKUFlGJDyaN1xVS3m tcXZbwPVXCZjLcYgajIAPmtexYLSn09hVFb/MLIOPcc9gCd2JEkjK4rbtSVg6tTsyJTg2O0ne X6g4e6HHZu1LPOFDiVMEQ7d5eX4MRcHbbwPgMWXVK3BzI+rhs9ZAu/QAE4ycEZB+qLwrOgfC3 3UJ/KQ9WBRklUR2ryb84TL/NB34/K05i50kJNG7AECW2jbbLC6swY66ch933Z73NtkVGCulQ8 uhgo34JyG/p1ENGTysSKAfzLU/Wmt+l3Ppym8JV9QOpdIiLHSfL4ZS7e3R19GonOy0wzRQtI+ 3ZxsRttUP7jDYoQaRvczfIgKpM+S5+W5JTQWxTBj5+SPc0waRWfaZ+O0mgMgaZhZdAeEJqwZ6 irS8F5e 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, 6 Apr 2017 21:45:33 +0200 A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/infiniband/hw/usnic/usnic_vnic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/usnic/usnic_vnic.c b/drivers/infiniband/hw/usnic/usnic_vnic.c index e7b0030254da..a00bb9940cea 100644 --- a/drivers/infiniband/hw/usnic/usnic_vnic.c +++ b/drivers/infiniband/hw/usnic/usnic_vnic.c @@ -312,7 +312,7 @@ static int usnic_vnic_alloc_res_chunk(struct usnic_vnic *vnic, } chunk->cnt = chunk->free_cnt = cnt; - chunk->res = kzalloc(sizeof(*(chunk->res))*cnt, GFP_KERNEL); + chunk->res = kcalloc(cnt, sizeof(*chunk->res), GFP_KERNEL); if (!chunk->res) return -ENOMEM;