Skip to content

Commit 5cb0999

Browse files
nikita-youshkuba-moo
authored andcommitted
net: renesas: rswitch: fix possible early skb release
When sending frame split into multiple descriptors, hardware processes descriptors one by one, including writing back DT values. The first descriptor could be already marked as completed when processing of next descriptors for the same frame is still in progress. Although only the last descriptor is configured to generate interrupt, completion of the first descriptor could be noticed by the driver when handling interrupt for the previous frame. Currently, driver stores skb in the entry that corresponds to the first descriptor. This results into skb could be unmapped and freed when hardware did not complete the send yet. This opens a window for corrupting the data being sent. Fix this by saving skb in the entry that corresponds to the last descriptor used to send the frame. Fixes: d2c96b9 ("net: rswitch: Add jumbo frames handling for TX") Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com> Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Link: https://patch.msgid.link/20241208095004.69468-2-nikita.yoush@cogentembedded.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent d02af27 commit 5cb0999

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/net/ethernet/renesas/rswitch.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,8 +1681,9 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
16811681
if (dma_mapping_error(ndev->dev.parent, dma_addr_orig))
16821682
goto err_kfree;
16831683

1684-
gq->skbs[gq->cur] = skb;
1685-
gq->unmap_addrs[gq->cur] = dma_addr_orig;
1684+
/* Stored the skb at the last descriptor to avoid skb free before hardware completes send */
1685+
gq->skbs[(gq->cur + nr_desc - 1) % gq->ring_size] = skb;
1686+
gq->unmap_addrs[(gq->cur + nr_desc - 1) % gq->ring_size] = dma_addr_orig;
16861687

16871688
/* DT_FSTART should be set at last. So, this is reverse order. */
16881689
for (i = nr_desc; i-- > 0; ) {

0 commit comments

Comments
 (0)