From patchwork Fri Apr 7 20:57:07 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: 9670389 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 00E20602B3 for ; Fri, 7 Apr 2017 20:57:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5ECC28663 for ; Fri, 7 Apr 2017 20:57:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D762C28652; Fri, 7 Apr 2017 20:57:41 +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 887E228652 for ; Fri, 7 Apr 2017 20:57:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752677AbdDGU5k (ORCPT ); Fri, 7 Apr 2017 16:57:40 -0400 Received: from mout.web.de ([217.72.192.78]:51971 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751174AbdDGU5j (ORCPT ); Fri, 7 Apr 2017 16:57:39 -0400 Received: from [192.168.1.2] ([77.181.117.94]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LlF9O-1cLblW3hf4-00b0lq; Fri, 07 Apr 2017 22:57:13 +0200 Subject: [PATCH 1/9] IB/IPoIB: Use kcalloc() in two functions From: SF Markus Elfring To: linux-rdma@vger.kernel.org, target-devel@vger.kernel.org, David Ahern , Doug Ledford , Erez Shitrit , Feras Daoud , Hal Rosenstock , Leon Romanovsky , Mark Bloch , Or Gerlitz , Paolo Abeni , Roi Dayan , Sagi Grimberg , Sean Hefty , Yuval Shaia , Zhu Yanjun Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: Date: Fri, 7 Apr 2017 22:57:07 +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:Se3UE7t0o0jS0QDYPo8FHYOm0gP/8sEYYIu3iIq/SnQ7na71q6j YtIpHBvg+wb7qtFa4Ho2l6rtJpMNYdCAowwSDc94AJT3aFvK/sKymdVAm9QmRDv8L+htCfG 1GF1/Jcc++ePOsa+cyb1JRpXh3+pWzI2I1/mYYcJAteprkigunSg1iIC0rAq55kgd+YpRs+ X/8HqQRSSgvImnlE9Mt/g== X-UI-Out-Filterresults: notjunk:1; V01:K0:p5e2SvcuxsU=:P4iFM/UAMUqgilKUMJ9e6a HzhyepHIxn82pw596y6wv7iI7wqq6asR7JQduVCw2H542CXZ56nX+y3cDc4LFc5RJjaPC4aBY TuBBdO2HzP1xjyt747ioC/Wyw2gEVOnH4I/2bh435p9IGJLm/M5OtoDYFE5EMl2WZljk9F6YO UERD8T4Cw0ols1vyodBz8UHfdPja6/cOUWgK1Pom0cc9UzyhiqSJK3GCadSMf8r4OIBIh5Xgj Bshe82GH7PaFtlPIMKx984sBXI2hMeTlS1khROHhsoJROZxD27LQL5cozFaV423gFON5nPjgM qbsg0KC9EWHhY1ca4PGD+IjXR1YglgnmrHr/zlu4Td23PCMqFbYn/UBBNJf7y5/FWZSzuLjqT DqPly11jvcCsw8+Qd5JKWIRw1JfyqD0xoEQmUjM1TInUc7n3gc61xOVNVb9qN4c9fkEyePfin ACCFFn6FlPRlrD0OlXAKx2wQqKvpMpS1Nhdp2wxGzhmhQFSDu4fGcJ8uPBUV8JL+mnIzKR7Lj H8+URw9nRGU4u2x9U6S9liWGquVVFWdmLsta2zUf4F7fGQ70l8zGEWR1HKHdzzzzYsDoB25dT bR0WRgiz2zxUq6sgW9YOAE6dnrVxlVsu5LlYlnBNpjMLalm6qZuLYT6sjAP1MtCb7shJ2yb/v Cgc0pbsyRVAzwbFCpcRqMqDYz+GGDS/oj2orT5Esa8n7m4yjbVPaXXSoXbH+sU+ua1q7bqQUx z4BEJFC967FzZWRRdwEjhlT0i7IAfy96ww+dz1+wz8y7bwCyB4wdGXiT0mg8v60Hmhn+G5L10 eLxnhiE Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Fri, 7 Apr 2017 17:43:51 +0200 Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Reviewed-by: Sagi Grimberg --- drivers/infiniband/ulp/ipoib/ipoib_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index d1d3fb7a6127..3d3e49fb15b7 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -1484,7 +1484,7 @@ static int ipoib_neigh_hash_init(struct ipoib_dev_priv *priv) return -ENOMEM; set_bit(IPOIB_STOP_NEIGH_GC, &priv->flags); size = roundup_pow_of_two(arp_tbl.gc_thresh3); - buckets = kzalloc(size * sizeof(*buckets), GFP_KERNEL); + buckets = kcalloc(size, sizeof(*buckets), GFP_KERNEL); if (!buckets) { kfree(htbl); return -ENOMEM; @@ -1628,7 +1628,7 @@ int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port) struct ipoib_dev_priv *priv = netdev_priv(dev); /* Allocate RX/TX "rings" to hold queued skbs */ - priv->rx_ring = kzalloc(ipoib_recvq_size * sizeof *priv->rx_ring, + priv->rx_ring = kcalloc(ipoib_recvq_size, sizeof(*priv->rx_ring), GFP_KERNEL); if (!priv->rx_ring) goto out;