diff options
author | David Gibson <dwg@au1.ibm.com> | 2006-10-21 13:24:13 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-21 16:35:06 -0400 |
commit | 047a66d4bb24aaf19f41d620f8f0534c2153cd0b (patch) | |
tree | 448062113a3fe5083354da6181310d76f1d52af6 /drivers | |
parent | d42552c3ace1fa1f16ae02ce642f4c733cec40ca (diff) |
[PATCH] ibmveth: Fix index increment calculation
The recent commit 751ae21c6cd1493e3d0a4935b08fb298b9d89773 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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ibmveth.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c index 2802db23d3cb..44c9f993dcc4 100644 --- a/drivers/net/ibmveth.c +++ b/drivers/net/ibmveth.c | |||
@@ -212,8 +212,8 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc | |||
212 | break; | 212 | break; |
213 | } | 213 | } |
214 | 214 | ||
215 | free_index = pool->consumer_index++ % pool->size; | 215 | free_index = pool->consumer_index; |
216 | pool->consumer_index = free_index; | 216 | pool->consumer_index = (pool->consumer_index + 1) % pool->size; |
217 | index = pool->free_map[free_index]; | 217 | index = pool->free_map[free_index]; |
218 | 218 | ||
219 | ibmveth_assert(index != IBM_VETH_INVALID_MAP); | 219 | ibmveth_assert(index != IBM_VETH_INVALID_MAP); |
@@ -329,8 +329,10 @@ static void ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter, u64 | |||
329 | adapter->rx_buff_pool[pool].buff_size, | 329 | adapter->rx_buff_pool[pool].buff_size, |
330 | DMA_FROM_DEVICE); | 330 | DMA_FROM_DEVICE); |
331 | 331 | ||
332 | free_index = adapter->rx_buff_pool[pool].producer_index++ % adapter->rx_buff_pool[pool].size; | 332 | free_index = adapter->rx_buff_pool[pool].producer_index; |
333 | adapter->rx_buff_pool[pool].producer_index = free_index; | 333 | adapter->rx_buff_pool[pool].producer_index |
334 | = (adapter->rx_buff_pool[pool].producer_index + 1) | ||
335 | % adapter->rx_buff_pool[pool].size; | ||
334 | adapter->rx_buff_pool[pool].free_map[free_index] = index; | 336 | adapter->rx_buff_pool[pool].free_map[free_index] = index; |
335 | 337 | ||
336 | mb(); | 338 | mb(); |