Commit 4418b27b authored by Markus Elfring's avatar Markus Elfring Committed by Doug Ledford

IB/hns: Use kcalloc() in hns_roce_buddy_init()

* 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: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent e1d717de
...@@ -127,11 +127,12 @@ static int hns_roce_buddy_init(struct hns_roce_buddy *buddy, int max_order) ...@@ -127,11 +127,12 @@ static int hns_roce_buddy_init(struct hns_roce_buddy *buddy, int max_order)
buddy->max_order = max_order; buddy->max_order = max_order;
spin_lock_init(&buddy->lock); spin_lock_init(&buddy->lock);
buddy->bits = kcalloc(buddy->max_order + 1,
buddy->bits = kzalloc((buddy->max_order + 1) * sizeof(long *), sizeof(*buddy->bits),
GFP_KERNEL); GFP_KERNEL);
buddy->num_free = kzalloc((buddy->max_order + 1) * sizeof(int *), buddy->num_free = kcalloc(buddy->max_order + 1,
GFP_KERNEL); sizeof(*buddy->num_free),
GFP_KERNEL);
if (!buddy->bits || !buddy->num_free) if (!buddy->bits || !buddy->num_free)
goto err_out; goto err_out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment