Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1278375 > unrolled thread

[PATCH v2 net 4/6] net: mvneta: fix error path for building skb

Started byMarcin Wojtas <mw@semihalf.com>
First post2015-11-26 19:10 +0100
Last post2015-11-26 19:40 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 net 4/6] net: mvneta: fix error path for building skb Marcin Wojtas <mw@semihalf.com> - 2015-11-26 19:10 +0100
    Re: [PATCH v2 net 4/6] net: mvneta: fix error path for building skb Simon Guinot <simon.guinot@sequanux.org> - 2015-11-26 19:40 +0100

#1278375 — [PATCH v2 net 4/6] net: mvneta: fix error path for building skb

FromMarcin Wojtas <mw@semihalf.com>
Date2015-11-26 19:10 +0100
Subject[PATCH v2 net 4/6] net: mvneta: fix error path for building skb
Message-ID<qz99w-gG-5@gated-at.bofh.it>
In the actual RX processing, there is same error path for both descriptor
ring refilling and building skb fails. This is not correct, because after
successful refill, the ring is already updated with newly allocated
buffer. Then, in case of build_skb() fail, hitherto code left the original
buffer unmapped.

This patch fixes above situation by swapping error check of skb build with
DMA-unmap of original buffer.

Signed-off-by: Marcin Wojtas <mw@semihalf.com>
Cc: <stable@vger.kernel.org> # v4.2+
Fixes a84e32894191 ("net: mvneta: fix refilling for Rx DMA buffers")
---
 drivers/net/ethernet/marvell/mvneta.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 0c3d923..62cf971 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1580,12 +1580,16 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
 		}
 
 		skb = build_skb(data, pp->frag_size > PAGE_SIZE ? 0 : pp->frag_size);
-		if (!skb)
-			goto err_drop_frame;
 
+		/* After refill old buffer has to be unmapped regardless
+		 * the skb is successfully built or not.
+		 */
 		dma_unmap_single(dev->dev.parent, phys_addr,
 				 MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE);
 
+		if (!skb)
+			goto err_drop_frame;
+
 		rcvd_pkts++;
 		rcvd_bytes += rx_bytes;
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1278395

FromSimon Guinot <simon.guinot@sequanux.org>
Date2015-11-26 19:40 +0100
Message-ID<qz9Cy-r1-17@gated-at.bofh.it>
In reply to#1278375

[Multipart message — attachments visible in raw view] — view raw

On Thu, Nov 26, 2015 at 07:08:11PM +0100, Marcin Wojtas wrote:
> In the actual RX processing, there is same error path for both descriptor
> ring refilling and building skb fails. This is not correct, because after
> successful refill, the ring is already updated with newly allocated
> buffer. Then, in case of build_skb() fail, hitherto code left the original
> buffer unmapped.
> 
> This patch fixes above situation by swapping error check of skb build with
> DMA-unmap of original buffer.
> 
> Signed-off-by: Marcin Wojtas <mw@semihalf.com>
> Cc: <stable@vger.kernel.org> # v4.2+
> Fixes a84e32894191 ("net: mvneta: fix refilling for Rx DMA buffers")
> ---
>  drivers/net/ethernet/marvell/mvneta.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 

Acked-by: Simon Guinot <simon.guinot@sequanux.org>

Thanks,

Simon

> diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
> index 0c3d923..62cf971 100644
> --- a/drivers/net/ethernet/marvell/mvneta.c
> +++ b/drivers/net/ethernet/marvell/mvneta.c
> @@ -1580,12 +1580,16 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
>  		}
>  
>  		skb = build_skb(data, pp->frag_size > PAGE_SIZE ? 0 : pp->frag_size);
> -		if (!skb)
> -			goto err_drop_frame;
>  
> +		/* After refill old buffer has to be unmapped regardless
> +		 * the skb is successfully built or not.
> +		 */
>  		dma_unmap_single(dev->dev.parent, phys_addr,
>  				 MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE);
>  
> +		if (!skb)
> +			goto err_drop_frame;
> +
>  		rcvd_pkts++;
>  		rcvd_bytes += rx_bytes;
>  
> -- 
> 1.8.3.1
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web