Skip to contentSkip to conversation

net: dwc-xlgmac: fix an error code in xlgmac_alloc_pages()

PATCH Applied Dan Carpenter 3 participants 3 messages Mar 21, 2017 – Mar 22, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: dwc-xlgmac: fix an error code in xlgmac_alloc_pages()

The dma_mapping_error() returns true if there is an error but we want to return -ENOMEM and not 1.

Fixes 65e0ace2c5cd ("net: dwc-xlgmac: Initial driver for DesignWare Enterprise Ethernet")
drivers/net/ethernet/synopsys/dwc-xlgmac-desc.c +2 -4
index 55c796ed7d26..39b5cb967bba 100644
@@ -335,7 +335,6 @@ static int xlgmac_alloc_pages(struct xlgmac_pdata *pdata,
 {
 	struct page *pages = NULL;
 	dma_addr_t pages_dma;
-	int ret;
 
 	/* Try to obtain pages, decreasing order if necessary */
 	gfp |= __GFP_COLD | __GFP_COMP | __GFP_NOWARN;
@@ -352,10 +351,9 @@ static int xlgmac_alloc_pages(struct xlgmac_pdata *pdata,
 	/* 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;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Dan Carpenter

The dma_mapping_error() returns true if there is an error but we want to return -ENOMEM and not 1.

Fixes 65e0ace2c5cd ("net: dwc-xlgmac: Initial driver for DesignWare Enterprise Ethernet")
drivers/net/ethernet/synopsys/dwc-xlgmac-desc.c +0 -1
index 55c796ed7d26..39b5cb967bba 100644
@@ -335,7 +335,6 @@ static int xlgmac_alloc_pages(struct xlgmac_pdata *pdata,
 {
 	struct page *pages = NULL;
 	dma_addr_t pages_dma;
-	int ret;
 
 	/* Try to obtain pages, decreasing order if necessary */
 	gfp |= __GFP_COLD | __GFP_COMP | __GFP_NOWARN;
@@ -352,10 +351,9 @@ static int xlgmac_alloc_pages(struct xlgmac_pdata *pdata,
 	/* Map the pages */
 	pages_dma = dma_map_page(pdata->dev, pages, 0,

drivers/net/ethernet/synopsys/dwc-xlgmac-desc.c static int xlgmac_alloc_pages(struct xlgmac_pdata *pdata, · line 359

Quoted 10 lines
drivers/net/ethernet/synopsys/dwc-xlgmac-desc.c +2 -3
 				 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;

Thanks for fixes.