Commit bd25fa7b authored by Tom Herbert's avatar Tom Herbert Committed by David S. Miller

net: cleanups in RX queue allocation

Clean up in RX queue allocation.  In netif_set_real_num_rx_queues
return error on attempt to set zero queues, or requested number is
greater than number of allocated queues.  In netif_alloc_rx_queues,
do BUG_ON if queue_count is zero.
Signed-off-by: default avatarTom Herbert <therbert@google.com>
Acked-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 55513fb4
...@@ -1583,12 +1583,12 @@ int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq) ...@@ -1583,12 +1583,12 @@ int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq)
{ {
int rc; int rc;
if (rxq < 1 || rxq > dev->num_rx_queues)
return -EINVAL;
if (dev->reg_state == NETREG_REGISTERED) { if (dev->reg_state == NETREG_REGISTERED) {
ASSERT_RTNL(); ASSERT_RTNL();
if (rxq > dev->num_rx_queues)
return -EINVAL;
rc = net_rx_queue_update_kobjects(dev, dev->real_num_rx_queues, rc = net_rx_queue_update_kobjects(dev, dev->real_num_rx_queues,
rxq); rxq);
if (rc) if (rc)
...@@ -5013,14 +5013,13 @@ static int netif_alloc_rx_queues(struct net_device *dev) ...@@ -5013,14 +5013,13 @@ static int netif_alloc_rx_queues(struct net_device *dev)
{ {
#ifdef CONFIG_RPS #ifdef CONFIG_RPS
unsigned int i, count = dev->num_rx_queues; unsigned int i, count = dev->num_rx_queues;
if (count) {
struct netdev_rx_queue *rx; struct netdev_rx_queue *rx;
BUG_ON(count < 1);
rx = kcalloc(count, sizeof(struct netdev_rx_queue), GFP_KERNEL); rx = kcalloc(count, sizeof(struct netdev_rx_queue), GFP_KERNEL);
if (!rx) { if (!rx) {
pr_err("netdev: Unable to allocate %u rx queues.\n", pr_err("netdev: Unable to allocate %u rx queues.\n", count);
count);
return -ENOMEM; return -ENOMEM;
} }
dev->_rx = rx; dev->_rx = rx;
...@@ -5031,7 +5030,6 @@ static int netif_alloc_rx_queues(struct net_device *dev) ...@@ -5031,7 +5030,6 @@ static int netif_alloc_rx_queues(struct net_device *dev)
*/ */
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
rx[i].first = rx; rx[i].first = rx;
}
#endif #endif
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment