Skip to content

Commit

Permalink
net: mvneta: fix error path for building skb
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Simon Guinot <[email protected]>
Cc: <[email protected]> # v4.2+
Fixes a84e328 ("net: mvneta: fix refilling for Rx DMA buffers")
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
wojtas-marcin authored and davem330 committed Dec 3, 2015
1 parent dc1aadf commit 26c17a1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/net/ethernet/marvell/mvneta.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 26c17a1

Please sign in to comment.