Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1619271
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/3] IB/srp: Use kmalloc_array() in srp_alloc_req_data() |
| Date | 2017-04-08 14:20 +0200 |
| Message-ID | <ttXvs-56J-5@gated-at.bofh.it> (permalink) |
| References | <ttXvs-56J-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 8 Apr 2017 11:11:44 +0200
Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kmalloc_array".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/ulp/srp/ib_srp.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index cee46266f434..cf8cb7206983 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -866,16 +866,17 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch)
for (i = 0; i < target->req_ring_size; ++i) {
req = &ch->req_ring[i];
- mr_list = kmalloc(target->mr_per_cmd * sizeof(void *),
- GFP_KERNEL);
+ mr_list = kmalloc_array(target->mr_per_cmd, sizeof(void *),
+ GFP_KERNEL);
if (!mr_list)
goto out;
if (srp_dev->use_fast_reg) {
req->fr_list = mr_list;
} else {
req->fmr_list = mr_list;
- req->map_page = kmalloc(srp_dev->max_pages_per_mr *
- sizeof(void *), GFP_KERNEL);
+ req->map_page = kmalloc_array(srp_dev->max_pages_per_mr,
+ sizeof(void *),
+ GFP_KERNEL);
if (!req->map_page)
goto out;
}
--
2.12.2
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/3] InfiniBand-SRP: Fine-tuning for some function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-08 14:20 +0200
[PATCH 1/3] IB/srp: Use kmalloc_array() in srp_alloc_req_data() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-08 14:20 +0200
[PATCH 3/3] IB/srp: Delete unwanted spaces behind usages of the sizeof operator SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-08 14:20 +0200
[PATCH 2/3] IB/srp: Enclose 14 expressions for the sizeof operator by parentheses SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-08 14:20 +0200
Re: [PATCH 2/3] IB/srp: Enclose 14 expressions for the sizeof operator by parentheses Joe Perches <joe@perches.com> - 2017-04-08 17:00 +0200
csiph-web