OSDN Git Service

staging: rdma: use kmalloc_array instead of kmalloc
authorGeliang Tang <geliangtang@163.com>
Sun, 8 Nov 2015 14:17:52 +0000 (22:17 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 20 Nov 2015 00:55:37 +0000 (16:55 -0800)
Use kmalloc_array instead of kmalloc to allocate memory for an array.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rdma/amso1100/c2.c
drivers/staging/rdma/ipath/ipath_file_ops.c

index af043f0..b46ebd1 100644 (file)
@@ -111,7 +111,8 @@ static int c2_tx_ring_alloc(struct c2_ring *tx_ring, void *vaddr,
        struct c2_element *elem;
        int i;
 
-       tx_ring->start = kmalloc(sizeof(*elem) * tx_ring->count, GFP_KERNEL);
+       tx_ring->start = kmalloc_array(tx_ring->count, sizeof(*elem),
+                                      GFP_KERNEL);
        if (!tx_ring->start)
                return -ENOMEM;
 
@@ -160,7 +161,8 @@ static int c2_rx_ring_alloc(struct c2_ring *rx_ring, void *vaddr,
        struct c2_element *elem;
        int i;
 
-       rx_ring->start = kmalloc(sizeof(*elem) * rx_ring->count, GFP_KERNEL);
+       rx_ring->start = kmalloc_array(rx_ring->count, sizeof(*elem),
+                                      GFP_KERNEL);
        if (!rx_ring->start)
                return -ENOMEM;
 
index 13c3cd1..6187b84 100644 (file)
@@ -917,15 +917,15 @@ static int ipath_create_user_egr(struct ipath_portdata *pd)
        chunk = pd->port_rcvegrbuf_chunks;
        egrperchunk = pd->port_rcvegrbufs_perchunk;
        size = pd->port_rcvegrbuf_size;
-       pd->port_rcvegrbuf = kmalloc(chunk * sizeof(pd->port_rcvegrbuf[0]),
-                                    GFP_KERNEL);
+       pd->port_rcvegrbuf = kmalloc_array(chunk, sizeof(pd->port_rcvegrbuf[0]),
+                                          GFP_KERNEL);
        if (!pd->port_rcvegrbuf) {
                ret = -ENOMEM;
                goto bail;
        }
        pd->port_rcvegrbuf_phys =
-               kmalloc(chunk * sizeof(pd->port_rcvegrbuf_phys[0]),
-                       GFP_KERNEL);
+               kmalloc_array(chunk, sizeof(pd->port_rcvegrbuf_phys[0]),
+                             GFP_KERNEL);
        if (!pd->port_rcvegrbuf_phys) {
                ret = -ENOMEM;
                goto bail_rcvegrbuf;