sched: qdisc_reset_all_tx is calling qdisc_reset without qdisc_lock
authorJohn Fastabend <john.r.fastabend@intel.com>
Thu, 1 Jul 2010 13:21:35 +0000 (13:21 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 3 Jul 2010 04:59:07 +0000 (21:59 -0700)
When calling qdisc_reset() the qdisc lock needs to be held.  In
this case there is at least one driver i4l which is using this
without holding the lock.  Add the locking here.

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/sch_generic.h

index 03ca5d826757bb0459b3e612b5fdf5ae03757e9b..ba749be1e35463f39cf108a89a61ee43d1260615 100644 (file)
@@ -317,8 +317,16 @@ extern void tcf_destroy_chain(struct tcf_proto **fl);
 static inline void qdisc_reset_all_tx(struct net_device *dev)
 {
        unsigned int i;
-       for (i = 0; i < dev->num_tx_queues; i++)
-               qdisc_reset(netdev_get_tx_queue(dev, i)->qdisc);
+       struct Qdisc *qdisc;
+
+       for (i = 0; i < dev->num_tx_queues; i++) {
+               qdisc = netdev_get_tx_queue(dev, i)->qdisc;
+               if (qdisc) {
+                       spin_lock_bh(qdisc_lock(qdisc));
+                       qdisc_reset(qdisc);
+                       spin_unlock_bh(qdisc_lock(qdisc));
+               }
+       }
 }
 
 /* Are all TX queues of the device empty?  */