net/mlx5e: Fix dangling page pointer on DMA mapping error
authorEran Ben Elisha <eranbe@mellanox.com>
Wed, 16 Aug 2017 11:37:11 +0000 (14:37 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Wed, 30 Aug 2017 18:20:43 +0000 (21:20 +0300)
Function mlx5e_dealloc_rx_wqe is using page pointer value as an
indication to valid DMA mapping. In case that the mapping failed, we
released the page but kept the dangling pointer. Store the page pointer
only after the DMA mapping passed to avoid invalid page DMA unmap.

Fixes: bc77b240b3c5 ("net/mlx5e: Add fragmented memory support for RX multi packet WQE")
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c

index 325b2c8c1c6d18c8d8544ee15d0fcf0a347f6ee8..7344433259fca32fe288ba4c63dff6c64ab2d126 100644 (file)
@@ -222,13 +222,13 @@ static inline int mlx5e_page_alloc_mapped(struct mlx5e_rq *rq,
        if (unlikely(!page))
                return -ENOMEM;
 
-       dma_info->page = page;
        dma_info->addr = dma_map_page(rq->pdev, page, 0,
                                      RQ_PAGE_SIZE(rq), rq->buff.map_dir);
        if (unlikely(dma_mapping_error(rq->pdev, dma_info->addr))) {
                put_page(page);
                return -ENOMEM;
        }
+       dma_info->page = page;
 
        return 0;
 }