diff options
author | Changli Gao <xiaosuo@gmail.com> | 2010-12-04 02:31:41 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-12-08 09:43:27 -0800 |
commit | aa9421041128abb4d269ee1dc502ff65fb3b7d69 (patch) | |
tree | b464784fb21d80f03bc79ab1c5d3eb813d128d29 | |
parent | a1044e36e457fb6dbdf90ce756d578b251d99b5e (diff) | |
download | linux-aa9421041128abb4d269ee1dc502ff65fb3b7d69.tar.gz linux-aa9421041128abb4d269ee1dc502ff65fb3b7d69.tar.bz2 linux-aa9421041128abb4d269ee1dc502ff65fb3b7d69.zip |
net: init ingress queue
The dev field of ingress queue is forgot to initialized, then NULL
pointer dereference happens in qdisc_alloc().
Move inits of tx queues to netif_alloc_netdev_queues().
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/core/dev.c | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 55ff66fabce4..ee605c0867e7 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5112,11 +5112,21 @@ static int netif_alloc_rx_queues(struct net_device *dev) } #endif +static void netdev_init_one_queue(struct net_device *dev, + struct netdev_queue *queue, void *_unused) +{ + /* Initialize queue lock */ + spin_lock_init(&queue->_xmit_lock); + netdev_set_xmit_lockdep_class(&queue->_xmit_lock, dev->type); + queue->xmit_lock_owner = -1; + netdev_queue_numa_node_write(queue, -1); + queue->dev = dev; +} + static int netif_alloc_netdev_queues(struct net_device *dev) { unsigned int count = dev->num_tx_queues; struct netdev_queue *tx; - int i; BUG_ON(count < 1); @@ -5128,27 +5138,10 @@ static int netif_alloc_netdev_queues(struct net_device *dev) } dev->_tx = tx; - for (i = 0; i < count; i++) { - netdev_queue_numa_node_write(&tx[i], -1); - tx[i].dev = dev; - } - return 0; -} - -static void netdev_init_one_queue(struct net_device *dev, - struct netdev_queue *queue, - void *_unused) -{ - /* Initialize queue lock */ - spin_lock_init(&queue->_xmit_lock); - netdev_set_xmit_lockdep_class(&queue->_xmit_lock, dev->type); - queue->xmit_lock_owner = -1; -} - -static void netdev_init_queues(struct net_device *dev) -{ netdev_for_each_tx_queue(dev, netdev_init_one_queue, NULL); spin_lock_init(&dev->tx_global_lock); + + return 0; } /** @@ -5187,8 +5180,6 @@ int register_netdevice(struct net_device *dev) dev->iflink = -1; - netdev_init_queues(dev); - /* Init, if this function is available */ if (dev->netdev_ops->ndo_init) { ret = dev->netdev_ops->ndo_init(dev); |