]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rtase: fix double free of multi-frag skb on DMA map failure
authorYun Lu <luyun@kylinos.cn>
Tue, 21 Jul 2026 02:38:36 +0000 (10:38 +0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 28 Jul 2026 01:16:42 +0000 (18:16 -0700)
In rtase_start_xmit(), when the head buffer DMA mapping fails after
rtase_xmit_frags() has mapped all fragments, the error path clears
the fragment descriptors with rtase_tx_clear_range(), which frees
the skb through the last-frag slot and accounts tx_dropped. Control
then falls through to the common error label, which frees the same
skb a second time and counts it again.

Return right after clearing the fragments when the skb owns frags;
the no-frag case still drops through and frees the head skb once.

Fixes: d6e882b89fdf ("rtase: Implement .ndo_start_xmit function")
Signed-off-by: Yun Lu <luyun@kylinos.cn>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Justin Lai <justinlai0215@realtek.com>
Link: https://patch.msgid.link/20260721023836.6691-1-luyun_611@163.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/realtek/rtase/rtase_main.c

index 4168ad9e48eacacb4be1b0bd692c462d4fd7af78..e3cd4f7c138048ff434adcc18059cf7cdc7a4ede 100644 (file)
@@ -1623,6 +1623,9 @@ static netdev_tx_t rtase_start_xmit(struct sk_buff *skb,
 err_dma_1:
        ring->skbuff[entry] = NULL;
        rtase_tx_clear_range(ring, ring->cur_idx + 1, frags);
+       if (frags)
+               /* the frags were cleared above, along with the skb */
+               return NETDEV_TX_OK;
 
 err_dma_0:
        tp->stats.tx_dropped++;