Skip to contentSkip to conversation

net: init ingress queue

PATCH In review Changli Gao 3 participants 3 messages Dec 4, 2010 – Dec 5, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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().

---
v2: factorize the two inits in netdev_init_queues() and move inits of
tx queues to netif_alloc_netdev_queues().

 net/core/dev.c |   35 +++++++++++++----------------------
 1 file changed, 13 insertions(+), 22 deletions(-)
net/core/dev.c +13 -22
index cd24374..4a7fc32 100644
@@ -5109,11 +5109,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);
 
@@ -5125,27 +5135,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;
 }
 
 /**
@@ -5184,8 +5177,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);
#1 lore raw

net/core/dev.c

Quoted 15 lines · Changli Gao

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().

---
v2: factorize the two inits in netdev_init_queues() and move inits of
tx queues to netif_alloc_netdev_queues().

 net/core/dev.c |   35 +++++++++++++----------------------
 1 file changed, 13 insertions(+), 22 deletions(-)
net/core/dev.c +0 -0
index cd24374..4a7fc32 100644

I guess you should mention it's net-next problem, because some people might be unnecessarily concerned (why they don't have such an oops ;-)

Jarek P.

Acked-by on v1 1/1
#2 lore raw
In reply to Changli Gao
Quoted 9 lines · Changli Gao

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().

---
v2: factorize the two inits in netdev_init_queues() and move inits of
tx queues to netif_alloc_netdev_queues().

This is a net-next-2.6 patch, you forgot to mention it.