be2net: fix bad queue traversal in be_rx_q_clean()
authorSathya Perla <sathyap@serverengines.com>
Mon, 10 Aug 2009 03:43:23 +0000 (03:43 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 13 Aug 2009 05:13:17 +0000 (22:13 -0700)
Using "for(tail != head)" to traverse a queue from tail to head
fails in the case of a fully filled queue. Use "for(used != 0)" instead.

Signed-off-by: Sathya Perla <sathyap@serverengines.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/benet/be_main.c

index acce6a63932417c826c383df3e1706d7db5919cd..9bbf447ee28f6712fb97a52969bb3eb8a03a0442 100644 (file)
@@ -1010,7 +1010,7 @@ static void be_rx_q_clean(struct be_adapter *adapter)
 
        /* Then free posted rx buffer that were not used */
        tail = (rxq->head + rxq->len - atomic_read(&rxq->used)) % rxq->len;
-       for (; tail != rxq->head; index_inc(&tail, rxq->len)) {
+       for (; atomic_read(&rxq->used) > 0; index_inc(&tail, rxq->len)) {
                page_info = get_rx_page_info(adapter, tail);
                put_page(page_info->page);
                memset(page_info, 0, sizeof(*page_info));