Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1582398 > unrolled thread

[PATCH 2/2] IB/hns: Use kcalloc() in hns_roce_buddy_init()

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-02-16 10:10 +0100
Last post2017-02-16 10:10 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/2] IB/hns: Use kcalloc() in hns_roce_buddy_init() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-02-16 10:10 +0100

#1582398 — [PATCH 2/2] IB/hns: Use kcalloc() in hns_roce_buddy_init()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-02-16 10:10 +0100
Subject[PATCH 2/2] IB/hns: Use kcalloc() in hns_roce_buddy_init()
Message-ID<tbqeB-46b-7@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 16 Feb 2017 09:30:55 +0100

* 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.

* 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 <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/hns/hns_roce_mr.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c
index 4139abee3b54..b48693510727 100644
--- a/drivers/infiniband/hw/hns/hns_roce_mr.c
+++ b/drivers/infiniband/hw/hns/hns_roce_mr.c
@@ -127,11 +127,12 @@ static int hns_roce_buddy_init(struct hns_roce_buddy *buddy, int max_order)
 
 	buddy->max_order = max_order;
 	spin_lock_init(&buddy->lock);
-
-	buddy->bits = kzalloc((buddy->max_order + 1) * sizeof(long *),
-			       GFP_KERNEL);
-	buddy->num_free = kzalloc((buddy->max_order + 1) * sizeof(int *),
-				   GFP_KERNEL);
+	buddy->bits = kcalloc(buddy->max_order + 1,
+			      sizeof(*buddy->bits),
+			      GFP_KERNEL);
+	buddy->num_free = kcalloc(buddy->max_order + 1,
+				  sizeof(*buddy->num_free),
+				  GFP_KERNEL);
 	if (!buddy->bits || !buddy->num_free)
 		goto err_out;
 
-- 
2.11.1

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web