[PATCH] net: stmmac: unwind the XSK pool when the initial wakeup fails

Wentao Liang vulab at iscas.ac.cn
Tue Nov 3 18:53:42 PST 2026


stmmac_xdp_enable_pool() maps the XSK pool, reconfigures the queue for
zero-copy and only then wakes the RX NAPI. If that wakeup fails, for
example because the carrier dropped while the queue was being
reinitialized, the function returns an error without unmapping the
pool or restoring the queue. The mapping and its netdev reference are
then leaked, and the queue keeps a pointer to a pool that the caller is
about to destroy.

Roll the queue back to its non-zero-copy state through
stmmac_xdp_disable_pool(), which also drops the DMA mapping.

Fixes: bba2556efad6 ("net: stmmac: Enable RX via AF_XDP zero-copy")
Cc: stable at vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab at iscas.ac.cn>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c
index 9af9e0cb366c..4b18f03dddc9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c
@@ -6,6 +6,8 @@
 #include "stmmac.h"
 #include "stmmac_xdp.h"
 
+static int stmmac_xdp_disable_pool(struct stmmac_priv *priv, u16 queue);
+
 static int stmmac_xdp_enable_pool(struct stmmac_priv *priv,
 				  struct xsk_buff_pool *pool, u16 queue)
 {
@@ -48,8 +50,10 @@ static int stmmac_xdp_enable_pool(struct stmmac_priv *priv,
 		napi_enable(&ch->rxtx_napi);
 
 		err = stmmac_xsk_wakeup(priv->dev, queue, XDP_WAKEUP_RX);
-		if (err)
+		if (err) {
+			stmmac_xdp_disable_pool(priv, queue);
 			return err;
+		}
 	}
 
 	return 0;
-- 
2.34.1




More information about the linux-arm-kernel mailing list