Skip to content

Commit 3aa1417

Browse files
dramforeverkuba-moo
authored andcommitted
net: spacemit: Fix error handling in emac_alloc_rx_desc_buffers()
Even if we get a dma_mapping_error() while mapping an RX buffer, we should still update rx_ring->head to ensure that the buffers we were able to allocate and map are used. Fix this by breaking out to the existing code after the loop, analogous to the existing handling for skb allocation failure. Fixes: bfec6d7 ("net: spacemit: Add K1 Ethernet MAC") Signed-off-by: Vivian Wang <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 4245a79 commit 3aa1417

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

drivers/net/ethernet/spacemit/k1_emac.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,9 @@ static void emac_alloc_rx_desc_buffers(struct emac_priv *priv)
565565
DMA_FROM_DEVICE);
566566
if (dma_mapping_error(&priv->pdev->dev, rx_buf->dma_addr)) {
567567
dev_err_ratelimited(&ndev->dev, "Mapping skb failed\n");
568-
goto err_free_skb;
568+
dev_kfree_skb_any(skb);
569+
rx_buf->skb = NULL;
570+
break;
569571
}
570572

571573
rx_desc_addr = &((struct emac_desc *)rx_ring->desc_addr)[i];
@@ -590,10 +592,6 @@ static void emac_alloc_rx_desc_buffers(struct emac_priv *priv)
590592

591593
rx_ring->head = i;
592594
return;
593-
594-
err_free_skb:
595-
dev_kfree_skb_any(skb);
596-
rx_buf->skb = NULL;
597595
}
598596

599597
/* Returns number of packets received */

0 commit comments

Comments
 (0)