Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions drivers/net/ethernet/spacemit/k1_emac.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,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];
Expand All @@ -592,10 +594,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 */
Expand Down Expand Up @@ -737,7 +735,7 @@ static void emac_tx_mem_map(struct emac_priv *priv, struct sk_buff *skb)
struct emac_desc tx_desc, *tx_desc_addr;
struct device *dev = &priv->pdev->dev;
struct emac_tx_desc_buffer *tx_buf;
u32 head, old_head, frag_num, f;
u32 head, old_head, frag_num, f, i;
bool buf_idx;

frag_num = skb_shinfo(skb)->nr_frags;
Expand Down Expand Up @@ -805,6 +803,15 @@ static void emac_tx_mem_map(struct emac_priv *priv, struct sk_buff *skb)

err_free_skb:
dev_dstats_tx_dropped(priv->ndev);

i = old_head;
while (i != head) {
emac_free_tx_buf(priv, i);

if (++i == tx_ring->total_cnt)
i = 0;
}

dev_kfree_skb_any(skb);
}

Expand Down