diff options
author | Changli Gao <xiaosuo@gmail.com> | 2010-12-03 21:31:41 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-12-08 12:43:27 -0500 |
commit | aa9421041128abb4d269ee1dc502ff65fb3b7d69 (patch) | |
tree | b464784fb21d80f03bc79ab1c5d3eb813d128d29 | |
parent | a1044e36e457fb6dbdf90ce756d578b251d99b5e (diff) |
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) | |||
5112 | } | 5112 | } |
5113 | #endif | 5113 | #endif |
5114 | 5114 | ||
5115 | static void netdev_init_one_queue(struct net_device *dev, | ||
5116 | struct netdev_queue *queue, void *_unused) | ||
5117 | { | ||
5118 | /* Initialize queue lock */ | ||
5119 | spin_lock_init(&queue->_xmit_lock); | ||
5120 | netdev_set_xmit_lockdep_class(&queue->_xmit_lock, dev->type); | ||
5121 | queue->xmit_lock_owner = -1; | ||
5122 | netdev_queue_numa_node_write(queue, -1); | ||
5123 | queue->dev = dev; | ||
5124 | } | ||
5125 | |||
5115 | static int netif_alloc_netdev_queues(struct net_device *dev) | 5126 | static int netif_alloc_netdev_queues(struct net_device *dev) |
5116 | { | 5127 | { |
5117 | unsigned int count = dev->num_tx_queues; | 5128 | unsigned int count = dev->num_tx_queues; |
5118 | struct netdev_queue *tx; | 5129 | struct netdev_queue *tx; |
5119 | int i; | ||
5120 | 5130 | ||
5121 | BUG_ON(count < 1); | 5131 | BUG_ON(count < 1); |
5122 | 5132 | ||
@@ -5128,27 +5138,10 @@ static int netif_alloc_netdev_queues(struct net_device *dev) | |||
5128 | } | 5138 | } |
5129 | dev->_tx = tx; | 5139 | dev->_tx = tx; |
5130 | 5140 | ||
5131 | for (i = 0; i < count; i++) { | ||
5132 | netdev_queue_numa_node_write(&tx[i], -1); | ||
5133 | tx[i].dev = dev; | ||
5134 | } | ||
5135 | return 0; | ||
5136 | } | ||
5137 | |||
5138 | static void netdev_init_one_queue(struct net_device *dev, | ||
5139 | struct netdev_queue *queue, | ||
5140 | void *_unused) | ||
5141 | { | ||
5142 | /* Initialize queue lock */ | ||
5143 | spin_lock_init(&queue->_xmit_lock); | ||
5144 | netdev_set_xmit_lockdep_class(&queue->_xmit_lock, dev->type); | ||
5145 | queue->xmit_lock_owner = -1; | ||
5146 | } | ||
5147 | |||
5148 | static void netdev_init_queues(struct net_device *dev) | ||
5149 | { | ||
5150 | netdev_for_each_tx_queue(dev, netdev_init_one_queue, NULL); | 5141 | netdev_for_each_tx_queue(dev, netdev_init_one_queue, NULL); |
5151 | spin_lock_init(&dev->tx_global_lock); | 5142 | spin_lock_init(&dev->tx_global_lock); |
5143 | |||
5144 | return 0; | ||
5152 | } | 5145 | } |
5153 | 5146 | ||
5154 | /** | 5147 | /** |
@@ -5187,8 +5180,6 @@ int register_netdevice(struct net_device *dev) | |||
5187 | 5180 | ||
5188 | dev->iflink = -1; | 5181 | dev->iflink = -1; |
5189 | 5182 | ||
5190 | netdev_init_queues(dev); | ||
5191 | |||
5192 | /* Init, if this function is available */ | 5183 | /* Init, if this function is available */ |
5193 | if (dev->netdev_ops->ndo_init) { | 5184 | if (dev->netdev_ops->ndo_init) { |
5194 | ret = dev->netdev_ops->ndo_init(dev); | 5185 | ret = dev->netdev_ops->ndo_init(dev); |