Commit aed86616 authored by Dave Hansen's avatar Dave Hansen Committed by Linus Torvalds

[PATCH] ibmveth: race fixes

This patch fixes a race condition that would panic the kernel when
replenishing a buffer pool.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 01fbd2dc
......@@ -214,11 +214,12 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
free_index = pool->consumer_index++ % pool->size;
index = pool->free_map[free_index];
ibmveth_assert(index != 0xffff);
ibmveth_assert(index != IBM_VETH_INVALID_MAP);
ibmveth_assert(pool->skbuff[index] == NULL);
dma_addr = vio_map_single(adapter->vdev, skb->data, pool->buff_size, DMA_FROM_DEVICE);
pool->free_map[free_index] = IBM_VETH_INVALID_MAP;
pool->dma_addr[index] = dma_addr;
pool->skbuff[index] = skb;
......@@ -233,6 +234,7 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
lpar_rc = h_add_logical_lan_buffer(adapter->vdev->unit_address, desc.desc);
if(lpar_rc != H_Success) {
pool->free_map[free_index] = IBM_VETH_INVALID_MAP;
pool->skbuff[index] = NULL;
pool->consumer_index--;
vio_unmap_single(adapter->vdev, pool->dma_addr[index], pool->buff_size, DMA_FROM_DEVICE);
......@@ -240,7 +242,6 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
adapter->replenish_add_buff_failure++;
break;
} else {
pool->free_map[free_index] = 0xffff;
buffers_added++;
adapter->replenish_add_buff_success++;
}
......
......@@ -77,6 +77,8 @@
#define IbmVethPool1DftCnt 256
#define IbmVethPool2DftCnt 256
#define IBM_VETH_INVALID_MAP ((u16)0xffff)
struct ibmveth_buff_pool {
u32 size;
u32 index;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment