[-next] net: dwc-xlgmac: fix an error code in xlgmac_alloc_pages()
diff mbox

Message ID 20170321204227.GB22118@mwanda
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Dan Carpenter March 21, 2017, 8:42 p.m. UTC
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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Jie Deng March 22, 2017, 4:16 a.m. UTC | #1
On 2017/3/22 4:42, Dan Carpenter wrote:

> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/net/ethernet/synopsys/dwc-xlgmac-desc.c b/drivers/net/ethernet/synopsys/dwc-xlgmac-desc.c
> index 55c796ed7d26..39b5cb967bba 100644
> --- a/drivers/net/ethernet/synopsys/dwc-xlgmac-desc.c
> +++ b/drivers/net/ethernet/synopsys/dwc-xlgmac-desc.c
> @@ -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;
Thanks for fixes.
Reviewed-by: Jie Deng <jiedeng@synopsys.com>
David Miller March 22, 2017, 7:46 p.m. UTC | #2
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Tue, 21 Mar 2017 23:42:27 +0300

> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied, thanks Dan.

Patch
diff mbox

diff --git a/drivers/net/ethernet/synopsys/dwc-xlgmac-desc.c b/drivers/net/ethernet/synopsys/dwc-xlgmac-desc.c
index 55c796ed7d26..39b5cb967bba 100644
--- a/drivers/net/ethernet/synopsys/dwc-xlgmac-desc.c
+++ b/drivers/net/ethernet/synopsys/dwc-xlgmac-desc.c
@@ -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;