From patchwork Wed Mar 8 13:09:02 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: 9611037 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 71AA96016C for ; Wed, 8 Mar 2017 13:11:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5CA428585 for ; Wed, 8 Mar 2017 13:11:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAA292858D; Wed, 8 Mar 2017 13:11:36 +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 5A6E028585 for ; Wed, 8 Mar 2017 13:11:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753251AbdCHNLE (ORCPT ); Wed, 8 Mar 2017 08:11:04 -0500 Received: from mout.web.de ([212.227.15.3]:58320 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752266AbdCHNKX (ORCPT ); Wed, 8 Mar 2017 08:10:23 -0500 Received: from [192.168.1.2] ([92.228.144.238]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MCeX4-1cuyzN3od0-009OBW; Wed, 08 Mar 2017 14:09:04 +0100 Subject: [PATCH 13/26] IB/ocrdma: Use kcalloc() in ocrdma_alloc_resources() 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: <5c457559-d7a2-12ec-505c-5b030a425e47@users.sourceforge.net> Date: Wed, 8 Mar 2017 14:09:02 +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: X-Provags-ID: V03:K0:MqhGmxbu1ebEqpvdggSQ7s2nNZr9A3usFUXveIrhnAojYHmNQTi HKqZEXt43g2bGd30AXqQkTLECXGHR1JNzaprUVinW2llZ9tElx09rKr6hau1ytMgiT+x4jA luPg9jaMWt61oX5IXGXwLqmWvfbSVcSBBMvlyqPdNqmAeDeRh79RyBtcac90yoFteBmcUu+ iCl2xu9ov6UKnEKTnR9wg== X-UI-Out-Filterresults: notjunk:1; V01:K0:Vf3ovptUhhM=:X4IFcu63rPDt8B/tyMrlSx 3p2U7ZE1ReLuS74BWO5k+L/S5y/5g/cO6nojhAa9Jn4fjry2XnK3O4zO0G0LvCxJM0itL8oq8 Je1m63d653wptbTwQSTeMDBZx5zaeN50ZxEbJfwhzrYfIkssuRCg7GDK1W/T1X6bkuzoiSlQY mxpwt2uDkW95PIpTmA+3X6fvq+2XZrmYaixwqpoYSx8PD+RkPV9n/pxSNXttZdmKCrLgvjgLa Wde9JQ2Nk9Ts9JisB03ymQB/XGXix1FQuF6/0eR7vlNpcd+1OF4Rc2SS7Y4WB1Hv/B95Znem7 T6r5LB9Wr5jfSCJQ+8Z8hKt9U9XRNO8qLsQ5tV+TGuifnvBkvk6fZyFh54RgxI+sHCVwundaS 3ufRN+WVjj0Z23D3SXBLcNl51Inj9b667e5UKpeNj3FcJg2nUsiBn7NAlk4lqvEeLNbpra0Tr mWp7c0FAupXZtEw6Ov6fbkx7DXwKEXuutdUf40yMkgsszAjAPKHxrkP+qw5Ls9ds9+cMGamfP xzLdTkW7aW+y9H/3/MNhc50xl+SOXYrdQCsWrHVwpsYnXJEwAegROauMSjiMRoC6KkALLSEaW YPyObES7Q9o85a3LbWwisn9I8GCSnTOq6JnxhPy702SyEQgddI88sVLIyGDiFIuPLyZsLTEoM BLMs3nYDrg17PoSYZwyk9KJJqB0qjzoR4lfjRg0Y2p54PzfjN+eUvw5bP5oJ5QuBF7jhJlybP 9/MKp70go590bjGlqDkffE4tsG0WSimW48z721IdycD1thjnpkrW5qQVwfU9utWlk9nrxElQG /Ter2Hb 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: Tue, 7 Mar 2017 21:55:42 +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. * 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/ocrdma/ocrdma_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_main.c b/drivers/infiniband/hw/ocrdma/ocrdma_main.c index 3e43bdc81e7a..9caa4c564e34 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_main.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_main.c @@ -225,19 +225,19 @@ static int ocrdma_register_device(struct ocrdma_dev *dev) static int ocrdma_alloc_resources(struct ocrdma_dev *dev) { mutex_init(&dev->dev_lock); - dev->cq_tbl = kzalloc(sizeof(struct ocrdma_cq *) * - OCRDMA_MAX_CQ, GFP_KERNEL); + dev->cq_tbl = kcalloc(OCRDMA_MAX_CQ, sizeof(*dev->cq_tbl), GFP_KERNEL); if (!dev->cq_tbl) goto alloc_err; if (dev->attr.max_qp) { - dev->qp_tbl = kzalloc(sizeof(struct ocrdma_qp *) * - OCRDMA_MAX_QP, GFP_KERNEL); + dev->qp_tbl = kcalloc(OCRDMA_MAX_QP, sizeof(*dev->qp_tbl), + GFP_KERNEL); if (!dev->qp_tbl) goto alloc_err; } - dev->stag_arr = kzalloc(sizeof(u64) * OCRDMA_MAX_STAG, GFP_KERNEL); + dev->stag_arr = kcalloc(OCRDMA_MAX_STAG, sizeof(*dev->stag_arr), + GFP_KERNEL); if (dev->stag_arr == NULL) goto alloc_err;