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

Commit 14f8dc49 authored by Joe Perches's avatar Joe Perches Committed by David S. Miller
Browse files

drivers: net: Remove remaining alloc/OOM messages



alloc failures already get standardized OOM
messages and a dump_stack.

For the affected mallocs around these OOM messages:

Converted kmallocs with multiplies to kmalloc_array.
Converted a kmalloc/memcpy to kmemdup.
Removed now unused stack variables.
Removed unnecessary parentheses.
Neatened alignment.

Signed-off-by: default avatarJoe Perches <joe@perches.com>
Acked-by: default avatarArend van Spriel <arend@broadcom.com>
Acked-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
Acked-by: default avatarJohn W. Linville <linville@tuxdriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e9ba1039
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -1019,10 +1019,8 @@ static int ems_usb_probe(struct usb_interface *intf,

	dev->tx_msg_buffer = kzalloc(CPC_HEADER_SIZE +
				     sizeof(struct ems_cpc_msg), GFP_KERNEL);
	if (!dev->tx_msg_buffer) {
		dev_err(&intf->dev, "Couldn't alloc Tx buffer\n");
	if (!dev->tx_msg_buffer)
		goto cleanup_intr_in_buffer;
	}

	usb_set_intfdata(intf, dev);

+15 −32
Original line number Diff line number Diff line
@@ -494,19 +494,15 @@ static void pcnet32_realloc_tx_ring(struct net_device *dev,
	}
	memset(new_tx_ring, 0, sizeof(struct pcnet32_tx_head) * (1 << size));

	new_dma_addr_list = kcalloc((1 << size), sizeof(dma_addr_t),
	new_dma_addr_list = kcalloc(1 << size, sizeof(dma_addr_t),
				    GFP_ATOMIC);
	if (!new_dma_addr_list) {
		netif_err(lp, drv, dev, "Memory allocation failed\n");
	if (!new_dma_addr_list)
		goto free_new_tx_ring;
	}

	new_skb_list = kcalloc((1 << size), sizeof(struct sk_buff *),
	new_skb_list = kcalloc(1 << size, sizeof(struct sk_buff *),
			       GFP_ATOMIC);
	if (!new_skb_list) {
		netif_err(lp, drv, dev, "Memory allocation failed\n");
	if (!new_skb_list)
		goto free_new_lists;
	}

	kfree(lp->tx_skbuff);
	kfree(lp->tx_dma_addr);
@@ -564,19 +560,14 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev,
	}
	memset(new_rx_ring, 0, sizeof(struct pcnet32_rx_head) * (1 << size));

	new_dma_addr_list = kcalloc((1 << size), sizeof(dma_addr_t),
				GFP_ATOMIC);
	if (!new_dma_addr_list) {
		netif_err(lp, drv, dev, "Memory allocation failed\n");
	new_dma_addr_list = kcalloc(1 << size, sizeof(dma_addr_t), GFP_ATOMIC);
	if (!new_dma_addr_list)
		goto free_new_rx_ring;
	}

	new_skb_list = kcalloc((1 << size), sizeof(struct sk_buff *),
	new_skb_list = kcalloc(1 << size, sizeof(struct sk_buff *),
			       GFP_ATOMIC);
	if (!new_skb_list) {
		netif_err(lp, drv, dev, "Memory allocation failed\n");
	if (!new_skb_list)
		goto free_new_lists;
	}

	/* first copy the current receive buffers */
	overlap = min(size, lp->rx_ring_size);
@@ -1933,31 +1924,23 @@ static int pcnet32_alloc_ring(struct net_device *dev, const char *name)

	lp->tx_dma_addr = kcalloc(lp->tx_ring_size, sizeof(dma_addr_t),
				  GFP_ATOMIC);
	if (!lp->tx_dma_addr) {
		netif_err(lp, drv, dev, "Memory allocation failed\n");
	if (!lp->tx_dma_addr)
		return -ENOMEM;
	}

	lp->rx_dma_addr = kcalloc(lp->rx_ring_size, sizeof(dma_addr_t),
				  GFP_ATOMIC);
	if (!lp->rx_dma_addr) {
		netif_err(lp, drv, dev, "Memory allocation failed\n");
	if (!lp->rx_dma_addr)
		return -ENOMEM;
	}

	lp->tx_skbuff = kcalloc(lp->tx_ring_size, sizeof(struct sk_buff *),
				GFP_ATOMIC);
	if (!lp->tx_skbuff) {
		netif_err(lp, drv, dev, "Memory allocation failed\n");
	if (!lp->tx_skbuff)
		return -ENOMEM;
	}

	lp->rx_skbuff = kcalloc(lp->rx_ring_size, sizeof(struct sk_buff *),
				GFP_ATOMIC);
	if (!lp->rx_skbuff) {
		netif_err(lp, drv, dev, "Memory allocation failed\n");
	if (!lp->rx_skbuff)
		return -ENOMEM;
	}

	return 0;
}
+10 −15
Original line number Diff line number Diff line
@@ -277,14 +277,12 @@ static int gfar_alloc_skb_resources(struct net_device *ndev)
	/* Setup the skbuff rings */
	for (i = 0; i < priv->num_tx_queues; i++) {
		tx_queue = priv->tx_queue[i];
		tx_queue->tx_skbuff = kmalloc(sizeof(*tx_queue->tx_skbuff) *
					      tx_queue->tx_ring_size,
		tx_queue->tx_skbuff =
			kmalloc_array(tx_queue->tx_ring_size,
				      sizeof(*tx_queue->tx_skbuff),
				      GFP_KERNEL);
		if (!tx_queue->tx_skbuff) {
			netif_err(priv, ifup, ndev,
				  "Could not allocate tx_skbuff\n");
		if (!tx_queue->tx_skbuff)
			goto cleanup;
		}

		for (k = 0; k < tx_queue->tx_ring_size; k++)
			tx_queue->tx_skbuff[k] = NULL;
@@ -292,15 +290,12 @@ static int gfar_alloc_skb_resources(struct net_device *ndev)

	for (i = 0; i < priv->num_rx_queues; i++) {
		rx_queue = priv->rx_queue[i];
		rx_queue->rx_skbuff = kmalloc(sizeof(*rx_queue->rx_skbuff) *
					      rx_queue->rx_ring_size,
		rx_queue->rx_skbuff =
			kmalloc_array(rx_queue->rx_ring_size,
				      sizeof(*rx_queue->rx_skbuff),
				      GFP_KERNEL);

		if (!rx_queue->rx_skbuff) {
			netif_err(priv, ifup, ndev,
				  "Could not allocate rx_skbuff\n");
		if (!rx_queue->rx_skbuff)
			goto cleanup;
		}

		for (j = 0; j < rx_queue->rx_ring_size; j++)
			rx_queue->rx_skbuff[j] = NULL;
+3 −11
Original line number Diff line number Diff line
@@ -1509,11 +1509,8 @@ static int e1000_setup_tx_resources(struct e1000_adapter *adapter,

	size = sizeof(struct e1000_buffer) * txdr->count;
	txdr->buffer_info = vzalloc(size);
	if (!txdr->buffer_info) {
		e_err(probe, "Unable to allocate memory for the Tx descriptor "
		      "ring\n");
	if (!txdr->buffer_info)
		return -ENOMEM;
	}

	/* round up to nearest 4K */

@@ -1704,11 +1701,8 @@ static int e1000_setup_rx_resources(struct e1000_adapter *adapter,

	size = sizeof(struct e1000_buffer) * rxdr->count;
	rxdr->buffer_info = vzalloc(size);
	if (!rxdr->buffer_info) {
		e_err(probe, "Unable to allocate memory for the Rx descriptor "
		      "ring\n");
	if (!rxdr->buffer_info)
		return -ENOMEM;
	}

	desc_len = sizeof(struct e1000_rx_desc);

@@ -2252,10 +2246,8 @@ static void e1000_set_rx_mode(struct net_device *netdev)
	int mta_reg_count = E1000_NUM_MTA_REGISTERS;
	u32 *mcarray = kcalloc(mta_reg_count, sizeof(u32), GFP_ATOMIC);

	if (!mcarray) {
		e_err(probe, "memory allocation failed\n");
	if (!mcarray)
		return;
	}

	/* Check for Promiscuous and All Multicast modes */

+2 −8
Original line number Diff line number Diff line
@@ -708,11 +708,8 @@ ixgb_setup_tx_resources(struct ixgb_adapter *adapter)

	size = sizeof(struct ixgb_buffer) * txdr->count;
	txdr->buffer_info = vzalloc(size);
	if (!txdr->buffer_info) {
		netif_err(adapter, probe, adapter->netdev,
			  "Unable to allocate transmit descriptor ring memory\n");
	if (!txdr->buffer_info)
		return -ENOMEM;
	}

	/* round up to nearest 4K */

@@ -797,11 +794,8 @@ ixgb_setup_rx_resources(struct ixgb_adapter *adapter)

	size = sizeof(struct ixgb_buffer) * rxdr->count;
	rxdr->buffer_info = vzalloc(size);
	if (!rxdr->buffer_info) {
		netif_err(adapter, probe, adapter->netdev,
			  "Unable to allocate receive descriptor ring\n");
	if (!rxdr->buffer_info)
		return -ENOMEM;
	}

	/* Round up to nearest 4K */

Loading