Commit 3aa14178 authored by Vivian Wang's avatar Vivian Wang Committed by Jakub Kicinski
Browse files

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: bfec6d7f ("net: spacemit: Add K1 Ethernet MAC")
Signed-off-by: default avatarVivian Wang <wangruikang@iscas.ac.cn>
Link: https://patch.msgid.link/20260305-k1-ethernet-more-fixes-v2-1-e4e434d65055@iscas.ac.cn


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 4245a790
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -565,7 +565,9 @@ static void emac_alloc_rx_desc_buffers(struct emac_priv *priv)
						  DMA_FROM_DEVICE);
		if (dma_mapping_error(&priv->pdev->dev, rx_buf->dma_addr)) {
			dev_err_ratelimited(&ndev->dev, "Mapping skb failed\n");
			goto err_free_skb;
			dev_kfree_skb_any(skb);
			rx_buf->skb = NULL;
			break;
		}

		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)

	rx_ring->head = i;
	return;

err_free_skb:
	dev_kfree_skb_any(skb);
	rx_buf->skb = NULL;
}

/* Returns number of packets received */