[PATCH 3/3] staging: rdma: Replace kmalloc with kmalloc_array
Cristina Moraru
cristina.moraru09 at gmail.com
Wed Oct 21 01:20:22 EEST 2015
Replace kmalloc with specialized function kmalloc_array
when the size is a multiplication of:
number_of_elements * size_of_element
Signed-off-by: Cristina Moraru <cristina.moraru09 at gmail.com>
---
drivers/staging/rdma/amso1100/c2_provider.c | 2 +-
drivers/staging/rdma/ipath/ipath_verbs.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/rdma/amso1100/c2_provider.c b/drivers/staging/rdma/amso1100/c2_provider.c
index 956d76b..6597a62 100644
--- a/drivers/staging/rdma/amso1100/c2_provider.c
+++ b/drivers/staging/rdma/amso1100/c2_provider.c
@@ -462,7 +462,7 @@ static struct ib_mr *c2_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
shift = ffs(c2mr->umem->page_size) - 1;
n = c2mr->umem->nmap;
- pages = kmalloc(n * sizeof(u64), GFP_KERNEL);
+ pages = kmalloc_array(n, sizeof(u64), GFP_KERNEL);
if (!pages) {
err = -ENOMEM;
goto err;
diff --git a/drivers/staging/rdma/ipath/ipath_verbs.c b/drivers/staging/rdma/ipath/ipath_verbs.c
index 40f7f05..ea3f21a 100644
--- a/drivers/staging/rdma/ipath/ipath_verbs.c
+++ b/drivers/staging/rdma/ipath/ipath_verbs.c
@@ -2025,8 +2025,8 @@ int ipath_register_ib_device(struct ipath_devdata *dd)
dev = &idev->ibdev;
if (dd->ipath_sdma_descq_cnt) {
- tx = kmalloc(dd->ipath_sdma_descq_cnt * sizeof *tx,
- GFP_KERNEL);
+ tx = kmalloc_array(dd->ipath_sdma_descq_cnt, sizeof *tx,
+ GFP_KERNEL);
if (tx == NULL) {
ret = -ENOMEM;
goto err_tx;
--
1.9.1
More information about the firefly
mailing list