spidernet: transmit race
authorLinas Vepstas <linas@austin.ibm.com>
Tue, 20 Feb 2007 22:41:59 +0000 (16:41 -0600)
committerJeff Garzik <jeff@garzik.org>
Tue, 27 Feb 2007 09:16:03 +0000 (04:16 -0500)
Multiple threads performing a transmit can race into
the spidernet tx ring cleanup code. This puts the
relevant check under a lock.

Signed-off-by: Linas Vepstas <lins@austin.ibm.com>
Cc: Jens Osterkamp <Jens.Osterkamp@de.ibm.com>
Cc: Kou Ishizaki <kou.ishizaki@toshiba.co.jp>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/spider_net.c

index 15b0bcaec46725daa8d2d863eec5a8d9f7fadc0d..653a91adacc7b942ae5982756489049fb2470fa5 100644 (file)
@@ -803,8 +803,12 @@ spider_net_release_tx_chain(struct spider_net_card *card, int brutal)
        unsigned long flags;
        int status;
 
-       while (chain->tail != chain->head) {
+       while (1) {
                spin_lock_irqsave(&chain->lock, flags);
+               if (chain->tail == chain->head) {
+                       spin_unlock_irqrestore(&chain->lock, flags);
+                       return 0;
+               }
                descr = chain->tail;
                hwdescr = descr->hwdescr;