Skip to content

Commit

Permalink
mv643xx_eth: fix NULL pointer dereference in rxq_process()
Browse files Browse the repository at this point in the history
When we are low on memory, the assumption that every descriptor in the
receive ring will have an skbuff associated with it does not hold.

rxq_process() was assuming that if the receive descriptor it is working
on is not owned by the hardware, it can safely be processed and handed
to the networking stack.  But a descriptor in the receive ring not being
owned by the hardware can also happen when we are low on memory and did
not manage to refill the receive ring fully.

This patch changes rxq_process()'s bailout condition from "the first
receive descriptor to be processed is owned by the hardware" to "the
first receive descriptor to be processed is owned by the hardware OR
the number of valid receive descriptors in the ring is zero".

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
  • Loading branch information
Lennert Buytenhek authored and Lennert Buytenhek committed Aug 24, 2008
1 parent 8e0b1bf commit 9e1f377
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/mv643xx_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ static int rxq_process(struct rx_queue *rxq, int budget)
int rx;

rx = 0;
while (rx < budget) {
while (rx < budget && rxq->rx_desc_count) {
struct rx_desc *rx_desc;
unsigned int cmd_sts;
struct sk_buff *skb;
Expand Down

0 comments on commit 9e1f377

Please sign in to comment.