From: Linas Vepstas The RX packet handling can be called from several places, yet does not protect the rx ring structure. This patch places the ring buffer pointers under a lock. Signed-off-by: Linas Vepstas Cc: James K Lewis Cc: Arnd Bergmann Signed-off-by: Andrew Morton --- drivers/net/spider_net.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff -puN drivers/net/spider_net.c~spidernet-rx-locking drivers/net/spider_net.c --- a/drivers/net/spider_net.c~spidernet-rx-locking +++ a/drivers/net/spider_net.c @@ -969,28 +969,33 @@ static int spider_net_decode_one_descr(struct spider_net_card *card, int napi) { struct spider_net_descr_chain *chain = &card->rx_chain; - struct spider_net_descr *descr = chain->tail; + struct spider_net_descr *descr; int status; int result; + unsigned long flags; + + spin_lock_irqsave(&chain->lock, flags); + descr = chain->tail; status = spider_net_get_descr_status(descr); if (status == SPIDER_NET_DESCR_CARDOWNED) { /* nothing in the descriptor yet */ - result=0; - goto out; + spin_unlock_irqrestore(&chain->lock, flags); + return 0; } if (status == SPIDER_NET_DESCR_NOT_IN_USE) { /* not initialized yet, the ring must be empty */ + spin_unlock_irqrestore(&chain->lock, flags); spider_net_refill_rx_chain(card); spider_net_enable_rxdmac(card); - result=0; - goto out; + return 0; } /* descriptor definitively used -- move on tail */ chain->tail = descr->next; + spin_unlock_irqrestore(&chain->lock, flags); result = 0; if ( (status == SPIDER_NET_DESCR_RESPONSE_ERROR) || @@ -1022,7 +1027,6 @@ refill: /* change the descriptor state: */ if (!napi) spider_net_refill_rx_chain(card); -out: return result; } _