diff options
author | Konstantin Khlebnikov <khlebnikov@yandex-team.ru> | 2016-04-18 14:34:05 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-04-19 20:04:24 -0400 |
commit | 851b10d60879539bec8acecb35ed361393399282 (patch) | |
tree | 33f99b2a2017827402ed7b9215e249867ab56cbd | |
parent | 04aeb56a173282210c5dab5c9b3071fa3613806f (diff) | |
download | linux-851b10d60879539bec8acecb35ed361393399282.tar.gz linux-851b10d60879539bec8acecb35ed361393399282.tar.bz2 linux-851b10d60879539bec8acecb35ed361393399282.zip |
net/mlx4_en: do batched put_page using atomic_sub
This patch fixes couple error paths after allocation failures.
Atomic set of page reference counter is safe only if it is zero,
otherwise set can race with any speculative get_page_unless_zero.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/en_rx.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index 56d070d9cf01..7d25bc9c1b22 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -126,7 +126,9 @@ out: dma_unmap_page(priv->ddev, page_alloc[i].dma, page_alloc[i].page_size, PCI_DMA_FROMDEVICE); page = page_alloc[i].page; - set_page_count(page, 1); + /* Revert changes done by mlx4_alloc_pages */ + page_ref_sub(page, page_alloc[i].page_size / + priv->frag_info[i].frag_stride - 1); put_page(page); } } @@ -176,7 +178,9 @@ out: dma_unmap_page(priv->ddev, page_alloc->dma, page_alloc->page_size, PCI_DMA_FROMDEVICE); page = page_alloc->page; - set_page_count(page, 1); + /* Revert changes done by mlx4_alloc_pages */ + page_ref_sub(page, page_alloc->page_size / + priv->frag_info[i].frag_stride - 1); put_page(page); page_alloc->page = NULL; } |