mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v2] net: cxgb: Fix skb reference leak in ESPI workaround timers
@ 2026-11-08 10:34 Wentao Liang
  0 siblings, 0 replies; only message in thread
From: Wentao Liang @ 2026-11-08 10:34 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Andrew Lunn, netdev
  Cc: linux-kernel, vulab

From: Wentao Liang <vulab@iscas.ac.cn>
Date: Sun, 8 Nov 2026 10:09:23 +0000
Subject: [PATCH net v2] net: cxgb: Fix skb reference leak in ESPI workaround
 timers

espibug_workaround_t204() and espibug_workaround() take an extra
reference with skb_get() on the cached ARP skb before handing it to
t1_sge_tx(), so that the skb survives until the DMA has completed.

When the command queue is full, t1_sge_tx() returns NETDEV_TX_BUSY
without queueing the skb, and both callers ignore the return value, so
the extra reference is never dropped.

Drop the extra reference when t1_sge_tx() reports that it did not consume
the skb.

The candidate was found with static analysis tools; DeepSeek and GPT-6.1
Sol were used to audit it and to help prepare this fix.

Fixes: f1d3d38af757 ("[PATCH] chelsio: add support for other 10G boards")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
Changes in v2:
- Also fix the same leaked reference in espibug_workaround(), the
  single-port T2 timer callback, which has the identical pattern.
- Apologies for the very late respin; v1 was sent in a batch that went
  well over the netdev posting limits.
- Dropped Cc: stable@vger.kernel.org. This only leaks a reference on an
  error path in an old driver, so I leave the backport decision to you.
- Rebased on current mainline (fa4ad798f6f6). Build-tested on x86_64
  with W=1 (CONFIG_CHELSIO_T1=m): the cxgb module builds without warnings
  and checkpatch.pl is clean. The NETDEV_TX_BUSY path was not exercised
  at runtime.
- Link to v1: https://lore.kernel.org/all/20260917105425.2147804-1-vulab@iscas.ac.cn/

 drivers/net/ethernet/chelsio/cxgb/sge.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb/sge.c b/drivers/net/ethernet/chelsio/cxgb/sge.c
index d8fca697874a..87e6dbcc3ed7 100644
--- a/drivers/net/ethernet/chelsio/cxgb/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb/sge.c
@@ -2052,7 +2052,8 @@ static void espibug_workaround_t204(struct timer_list *t)
 			 * the skb once the DMA has completed.
 			 */
 			skb = skb_get(skb);
-			t1_sge_tx(skb, adapter, 0, adapter->port[i].dev);
+			if (t1_sge_tx(skb, adapter, 0, adapter->port[i].dev))
+				dev_kfree_skb_any(skb);
 		}
 	}
 	mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout);
@@ -2084,7 +2085,8 @@ static void espibug_workaround(struct timer_list *t)
 	                 * skb once the DMA has completed.
 	                 */
 	                skb = skb_get(skb);
-	                t1_sge_tx(skb, adapter, 0, adapter->port[0].dev);
+			if (t1_sge_tx(skb, adapter, 0, adapter->port[0].dev))
+				dev_kfree_skb_any(skb);
 	        }
 	}
 	mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout);
-- 
2.34.1



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-08 10:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-08 10:34 [PATCH net v2] net: cxgb: Fix skb reference leak in ESPI workaround timers Wentao Liang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®