amd-xgbe: use dma_mapping_error to check map errors
authorYueHaibing <yuehaibing@huawei.com>
Thu, 26 Jul 2018 01:51:27 +0000 (09:51 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 26 Jul 2018 04:17:17 +0000 (21:17 -0700)
The dma_mapping_error() returns true or false, but we want
to return -ENOMEM if there was an error.

Fixes: 174fd2597b0b ("amd-xgbe: Implement split header receive support")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/amd/xgbe/xgbe-desc.c

index cc1e4f820e64f39f28595750a4163bc64e7b1823..533094233659b6e218d87a1eb422a303eec98b65 100644 (file)
@@ -289,7 +289,7 @@ static int xgbe_alloc_pages(struct xgbe_prv_data *pdata,
        struct page *pages = NULL;
        dma_addr_t pages_dma;
        gfp_t gfp;
-       int order, ret;
+       int order;
 
 again:
        order = alloc_order;
@@ -316,10 +316,9 @@ again:
        /* Map the pages */
        pages_dma = dma_map_page(pdata->dev, pages, 0,
                                 PAGE_SIZE << order, DMA_FROM_DEVICE);
-       ret = dma_mapping_error(pdata->dev, pages_dma);
-       if (ret) {
+       if (dma_mapping_error(pdata->dev, pages_dma)) {
                put_page(pages);
-               return ret;
+               return -ENOMEM;
        }
 
        pa->pages = pages;