kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-rdma@vger.kernel.org, target-devel@vger.kernel.org,
	David Ahern <dsa@cumulusnetworks.com>,
	Doug Ledford <dledford@redhat.com>,
	Erez Shitrit <erezsh@mellanox.com>,
	Feras Daoud <ferasda@mellanox.com>,
	Hal Rosenstock <hal.rosenstock@gmail.com>,
	Leon Romanovsky <leon@kernel.org>,
	Mark Bloch <markb@mellanox.com>,
	Or Gerlitz <ogerlitz@mellanox.com>,
	Paolo Abeni <pabeni@redhat.com>, Roi Dayan <roid@mellanox.com>,
	Sagi Grimberg <sagi@grimberg.me>,
	Sean Hefty <sean.hefty@intel.com>,
	Yuval Shaia <yuval.shaia@oracle.com>,
	Zhu Yanjun <yanjun.zhu@oracle.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/9] IB/IPoIB: Use kcalloc() in two functions
Date: Fri, 07 Apr 2017 20:57:07 +0000	[thread overview]
Message-ID: <b6829c25-7c8b-858d-5cad-0322d6536f44@users.sourceforge.net> (raw)
In-Reply-To: <ce4249f2-c7e7-0282-2cff-3f9c3991efa3@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
 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


  reply	other threads:[~2017-04-07 20:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-07 20:54 [PATCH 0/9] InfiniBand-ULP: Fine-tuning for several function implementations SF Markus Elfring
2017-04-07 20:57 ` SF Markus Elfring [this message]
2017-04-09 12:26   ` [PATCH 1/9] IB/IPoIB: Use kcalloc() in two functions Sagi Grimberg
     [not found] ` <ce4249f2-c7e7-0282-2cff-3f9c3991efa3-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-04-07 21:00   ` [PATCH 2/9] IB/IPoIB: Delete an error message for a failed memory allocation SF Markus Elfring
2017-04-09 12:26     ` Sagi Grimberg
2017-04-07 21:03   ` [PATCH 4/9] IB/IPoIB: Delete unwanted spaces behind usages of the sizeof operator SF Markus Elfring
2017-04-09 12:26     ` Sagi Grimberg
2017-04-07 21:06   ` [PATCH 6/9] IB/iser: Use kmalloc_array() in iser_alloc_rx_descriptors() SF Markus Elfring
     [not found]     ` <75e5726b-d75f-1b79-1242-08f6440e1691-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2017-04-09  9:01       ` Sagi Grimberg
2017-04-07 21:08   ` [PATCH 8/9] IB/isert: Use kcalloc() in isert_alloc_rx_descriptors() SF Markus Elfring
2017-04-09  9:02     ` Sagi Grimberg
2017-04-07 21:01 ` [PATCH 3/9] IB/IPoIB: Enclose six expressions for the sizeof operator by parentheses SF Markus Elfring
2017-04-09 12:26   ` Sagi Grimberg
2017-04-07 21:05 ` [PATCH 5/9] IB/IPoIB: Combine substrings for three messages SF Markus Elfring
2017-04-18 11:33   ` Yuval Shaia
2017-04-07 21:07 ` [PATCH 7/9] IB/iser: Add spaces for better code readability SF Markus Elfring
2017-04-09  9:02   ` Sagi Grimberg
2017-04-07 21:09 ` [PATCH 9/9] IB/isert: Improve size determinations in three functions SF Markus Elfring
2017-04-09  9:02   ` Sagi Grimberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b6829c25-7c8b-858d-5cad-0322d6536f44@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=dledford@redhat.com \
    --cc=dsa@cumulusnetworks.com \
    --cc=erezsh@mellanox.com \
    --cc=ferasda@mellanox.com \
    --cc=hal.rosenstock@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=markb@mellanox.com \
    --cc=ogerlitz@mellanox.com \
    --cc=pabeni@redhat.com \
    --cc=roid@mellanox.com \
    --cc=sagi@grimberg.me \
    --cc=sean.hefty@intel.com \
    --cc=target-devel@vger.kernel.org \
    --cc=yanjun.zhu@oracle.com \
    --cc=yuval.shaia@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).