From patchwork Wed Mar 8 13:19:23 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: 9611099 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 EEA006046A for ; Wed, 8 Mar 2017 13:28:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C760628546 for ; Wed, 8 Mar 2017 13:28:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBCD428574; Wed, 8 Mar 2017 13:28:34 +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=unavailable 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 6BC4D28546 for ; Wed, 8 Mar 2017 13:28:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753483AbdCHN2I (ORCPT ); Wed, 8 Mar 2017 08:28:08 -0500 Received: from mout.web.de ([212.227.15.14]:51779 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752622AbdCHN1W (ORCPT ); Wed, 8 Mar 2017 08:27:22 -0500 Received: from [192.168.1.2] ([92.228.144.238]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MWAtV-1cjoCS1YnR-00XKUW; Wed, 08 Mar 2017 14:19:25 +0100 Subject: [PATCH 18/26] IB/ocrdma: Use kcalloc() in three functions 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: Date: Wed, 8 Mar 2017 14:19:23 +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:fZijR2JsMqzFr2o9g+3AT/s4AerRTotyk5hD1cvYlbVbY62mfnk DcJxr8vlc7bHXkHIy8S0KpxNsIPsDM4F6jDiDhkqU6Zbir95RRkh8oXYFU9zxxT9AbWmgnj TlcTQWOQ5fT1xiNl2b9t3BV2MgP2mNjUZgg965olfX1yRE9fBcG1VkBxh417ul5EtEfy4Tq +60pHIe8mC3bfERMf1NrQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:pP3SamyQmKM=:Ui+cyGpLtIjatIY4Plk4Eu f2DwxcsTvNA4H7YGJ8+y7l0bB/TD9PuqAxzVJ+U5Tv5h8LX8Xd3RLCw4tRMMGrAXw/v+pSVja ZcURE48rb7fmvnJRbRsOlXC5CX7LAyAZ4YMJNIlOYTZiDfzdD7iZonT8lRSykk9p+k088mZaa ApYqKqS+JBX3Rq57L9mc1+KV4lNd/UEM1H9jx4nnUVKao8eWQ4CmJ5TaQdVpLt/+oYZaeQ9CI OZE/KY9wAYJVx/pW2O//PB9/xQELEdF4X6tr4cMReOlo8ZbDe7azdFD3GF8yqyjShzWScvQWH AZ0s5RFW6yP9CaHeIa0UKfEaqv82P/ZLVqu4CZcDTN5XYf7uwfJ3mlzeOHUy1236n6FDc8DEU /YqmE43+ZHtgxCksCgOUaAzmEaNk5jDyuMfuGXPTDNgMkjN57tEBGeF6mkx6lplQx3SHdhNSj El9SHRLREkM0oTNxaSNAbmMiPn83urA/yg4TPGRKC3dAONnkY6QpoTs8AF1AJ7Izojt8UE/Yc 4FpFImi9tsDftSrrwdHtdnwbMqDWZdQyeNsLA7sJpUXzQz13XOcd+4PxO+ZpjlbQy0RLuSXF4 2pJaUainsGy8h1jsnuMC/nTeFg/mROqbR15SR9gDPkWwxQb1E0IZ7cAAxdWSDHtDzRo5W/K9l qD50AeIruwQ2mob6p0h4mHyBIaZ4WOoN63t9Kyz9Cfwkp4rLZD8+nekaDP0bT7pvWbQTbcPob VzDnerOQRR/++jt2l3j66i7fPRi8M7VbVXegLZkbyImatuN7mfbquq+gPXbFbUFJQXzS55nCM dsx+6EC 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: Wed, 8 Mar 2017 09:19:47 +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 Acked-By:Devesh Sharma --- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index ef670ac1cbe9..330617e1ef75 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c @@ -879,9 +879,8 @@ static int ocrdma_build_pbl_tbl(struct ocrdma_dev *dev, struct ocrdma_hw_mr *mr) void *va; dma_addr_t pa; - mr->pbl_table = kzalloc(sizeof(struct ocrdma_pbl) * - mr->num_pbls, GFP_KERNEL); - + mr->pbl_table = kcalloc(mr->num_pbls, sizeof(*mr->pbl_table), + GFP_KERNEL); if (!mr->pbl_table) return -ENOMEM; @@ -1362,13 +1361,12 @@ static void ocrdma_set_qp_db(struct ocrdma_dev *dev, struct ocrdma_qp *qp, static int ocrdma_alloc_wr_id_tbl(struct ocrdma_qp *qp) { - qp->wqe_wr_id_tbl = - kzalloc(sizeof(*(qp->wqe_wr_id_tbl)) * qp->sq.max_cnt, - GFP_KERNEL); + qp->wqe_wr_id_tbl = kcalloc(qp->sq.max_cnt, sizeof(*qp->wqe_wr_id_tbl), + GFP_KERNEL); if (qp->wqe_wr_id_tbl == NULL) return -ENOMEM; - qp->rqe_wr_id_tbl = - kzalloc(sizeof(u64) * qp->rq.max_cnt, GFP_KERNEL); + qp->rqe_wr_id_tbl = kcalloc(qp->rq.max_cnt, sizeof(*qp->rqe_wr_id_tbl), + GFP_KERNEL); if (qp->rqe_wr_id_tbl == NULL) return -ENOMEM; @@ -1903,8 +1901,9 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, goto err; if (udata == NULL) { - srq->rqe_wr_id_tbl = kzalloc(sizeof(u64) * srq->rq.max_cnt, - GFP_KERNEL); + srq->rqe_wr_id_tbl = kcalloc(srq->rq.max_cnt, + sizeof(*srq->rqe_wr_id_tbl), + GFP_KERNEL); if (srq->rqe_wr_id_tbl == NULL) goto arm_err;