Skip to content

Commit c71e3a5

Browse files
KenMilmorePaolo Abeni
authored andcommitted
r8169: Fix possible ring buffer corruption on fragmented Tx packets.
An issue was found on the RTL8125b when transmitting small fragmented packets, whereby invalid entries were inserted into the transmit ring buffer, subsequently leading to calls to dma_unmap_single() with a null address. This was caused by rtl8169_start_xmit() not noticing changes to nr_frags which may occur when small packets are padded (to work around hardware quirks) in rtl8169_tso_csum_v2(). To fix this, postpone inspecting nr_frags until after any padding has been applied. Fixes: 9020845 ("r8169: improve rtl8169_start_xmit") Cc: [email protected] Signed-off-by: Ken Milmore <[email protected]> Reviewed-by: Heiner Kallweit <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 3d8597d commit c71e3a5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/ethernet/realtek/r8169_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4337,11 +4337,11 @@ static void rtl8169_doorbell(struct rtl8169_private *tp)
43374337
static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
43384338
struct net_device *dev)
43394339
{
4340-
unsigned int frags = skb_shinfo(skb)->nr_frags;
43414340
struct rtl8169_private *tp = netdev_priv(dev);
43424341
unsigned int entry = tp->cur_tx % NUM_TX_DESC;
43434342
struct TxDesc *txd_first, *txd_last;
43444343
bool stop_queue, door_bell;
4344+
unsigned int frags;
43454345
u32 opts[2];
43464346

43474347
if (unlikely(!rtl_tx_slots_avail(tp))) {
@@ -4364,6 +4364,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
43644364

43654365
txd_first = tp->TxDescArray + entry;
43664366

4367+
frags = skb_shinfo(skb)->nr_frags;
43674368
if (frags) {
43684369
if (rtl8169_xmit_frags(tp, skb, opts, entry))
43694370
goto err_dma_1;

0 commit comments

Comments
 (0)