Skip to content

Commit

Permalink
[PATCH] ibmveth: Fix index increment calculation
Browse files Browse the repository at this point in the history
The recent commit 751ae21 introduced a bug
in the producer/consumer index calculation in the ibmveth driver -
incautious use of the post-increment ++ operator resulted in an increment
being immediately reverted.  This patch corrects the logic.

Without this patch, the driver oopses almost immediately after activation
on at least some machines.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
Acked-by: Santiago Leon <santil@us.ibm.com>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
David Gibson authored and Linus Torvalds committed Oct 21, 2006
1 parent d42552c commit 047a66d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/net/ibmveth.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
break;
}

free_index = pool->consumer_index++ % pool->size;
pool->consumer_index = free_index;
free_index = pool->consumer_index;
pool->consumer_index = (pool->consumer_index + 1) % pool->size;
index = pool->free_map[free_index];

ibmveth_assert(index != IBM_VETH_INVALID_MAP);
Expand Down Expand Up @@ -329,8 +329,10 @@ static void ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter, u64
adapter->rx_buff_pool[pool].buff_size,
DMA_FROM_DEVICE);

free_index = adapter->rx_buff_pool[pool].producer_index++ % adapter->rx_buff_pool[pool].size;
adapter->rx_buff_pool[pool].producer_index = free_index;
free_index = adapter->rx_buff_pool[pool].producer_index;
adapter->rx_buff_pool[pool].producer_index
= (adapter->rx_buff_pool[pool].producer_index + 1)
% adapter->rx_buff_pool[pool].size;
adapter->rx_buff_pool[pool].free_map[free_index] = index;

mb();
Expand Down

0 comments on commit 047a66d

Please sign in to comment.