staging: rdma: Replace kmalloc with kmalloc_array
authorCristina Moraru <cristina.moraru09@gmail.com>
Wed, 21 Oct 2015 17:00:51 +0000 (20:00 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 Oct 2015 02:00:15 +0000 (19:00 -0700)
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@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rdma/amso1100/c2_provider.c
drivers/staging/rdma/ipath/ipath_verbs.c

index 25632158a52a144439631871a5434180035f54f9..c707e45887c25004bb8265c93ab137681082f2fe 100644 (file)
@@ -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;
index 40f7f059f6b2efb6a3f040237da772e3490cf9e5..ea3f21aa0b38c7210989a2bf94c18ec884d7a6d9 100644 (file)
@@ -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;