Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b3e676b authored by Geliang Tang's avatar Geliang Tang Committed by Greg Kroah-Hartman
Browse files

staging: rdma: use kmalloc_array instead of kmalloc



Use kmalloc_array instead of kmalloc to allocate memory for an array.

Signed-off-by: default avatarGeliang Tang <geliangtang@163.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b629a6f6
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -111,7 +111,8 @@ static int c2_tx_ring_alloc(struct c2_ring *tx_ring, void *vaddr,
	struct c2_element *elem;
	struct c2_element *elem;
	int i;
	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)
	if (!tx_ring->start)
		return -ENOMEM;
		return -ENOMEM;


@@ -160,7 +161,8 @@ static int c2_rx_ring_alloc(struct c2_ring *rx_ring, void *vaddr,
	struct c2_element *elem;
	struct c2_element *elem;
	int i;
	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)
	if (!rx_ring->start)
		return -ENOMEM;
		return -ENOMEM;


+4 −4
Original line number Original line Diff line number Diff line
@@ -917,14 +917,14 @@ static int ipath_create_user_egr(struct ipath_portdata *pd)
	chunk = pd->port_rcvegrbuf_chunks;
	chunk = pd->port_rcvegrbuf_chunks;
	egrperchunk = pd->port_rcvegrbufs_perchunk;
	egrperchunk = pd->port_rcvegrbufs_perchunk;
	size = pd->port_rcvegrbuf_size;
	size = pd->port_rcvegrbuf_size;
	pd->port_rcvegrbuf = kmalloc(chunk * sizeof(pd->port_rcvegrbuf[0]),
	pd->port_rcvegrbuf = kmalloc_array(chunk, sizeof(pd->port_rcvegrbuf[0]),
					   GFP_KERNEL);
					   GFP_KERNEL);
	if (!pd->port_rcvegrbuf) {
	if (!pd->port_rcvegrbuf) {
		ret = -ENOMEM;
		ret = -ENOMEM;
		goto bail;
		goto bail;
	}
	}
	pd->port_rcvegrbuf_phys =
	pd->port_rcvegrbuf_phys =
		kmalloc(chunk * sizeof(pd->port_rcvegrbuf_phys[0]),
		kmalloc_array(chunk, sizeof(pd->port_rcvegrbuf_phys[0]),
			      GFP_KERNEL);
			      GFP_KERNEL);
	if (!pd->port_rcvegrbuf_phys) {
	if (!pd->port_rcvegrbuf_phys) {
		ret = -ENOMEM;
		ret = -ENOMEM;