Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932811AbdDGU5r (ORCPT ); Fri, 7 Apr 2017 16:57:47 -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 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-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit 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: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1490 Lines: 38 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 --- 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; -- 2.12.2