Skip to content

Commit 8629215

Browse files
dramforeverkuba-moo
authored andcommitted
net: spacemit: Fix error handling in emac_tx_mem_map()
The DMA mappings were leaked on mapping error. Free them with the existing emac_free_tx_buf() function. 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 3aa1417 commit 8629215

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

drivers/net/ethernet/spacemit/k1_emac.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ static void emac_tx_mem_map(struct emac_priv *priv, struct sk_buff *skb)
733733
struct emac_desc tx_desc, *tx_desc_addr;
734734
struct device *dev = &priv->pdev->dev;
735735
struct emac_tx_desc_buffer *tx_buf;
736-
u32 head, old_head, frag_num, f;
736+
u32 head, old_head, frag_num, f, i;
737737
bool buf_idx;
738738

739739
frag_num = skb_shinfo(skb)->nr_frags;
@@ -801,6 +801,15 @@ static void emac_tx_mem_map(struct emac_priv *priv, struct sk_buff *skb)
801801

802802
err_free_skb:
803803
dev_dstats_tx_dropped(priv->ndev);
804+
805+
i = old_head;
806+
while (i != head) {
807+
emac_free_tx_buf(priv, i);
808+
809+
if (++i == tx_ring->total_cnt)
810+
i = 0;
811+
}
812+
804813
dev_kfree_skb_any(skb);
805814
}
806815

0 commit comments

Comments
 (0)