DORMANTno replies

[PATCH] rocker: Fix memory leak in ofdpa_port_fdb()

From: Ziran Zhang <hidden>
Date: 2026-06-16 01:34:53
Also in: lkml
Subsystem: networking drivers, rocker driver, the rest · Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Jiri Pirko, Linus Torvalds

In ofdpa_port_fdb(), the hash_del() only unlinks the node from
hash table, but does not free it.

Fix this by adding kfree(found) after the !found == removing check,
where the pointer value is no longer needed.

Found by Coccinelle kfree script.

Signed-off-by: Ziran Zhang <redacted>
---
 drivers/net/ethernet/rocker/rocker_ofdpa.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/rocker/rocker_ofdpa.c b/drivers/net/ethernet/rocker/rocker_ofdpa.c
index 66a8ae67c..15d19a8a1 100644
--- a/drivers/net/ethernet/rocker/rocker_ofdpa.c
+++ b/drivers/net/ethernet/rocker/rocker_ofdpa.c
@@ -1924,6 +1924,9 @@ static int ofdpa_port_fdb(struct ofdpa_port *ofdpa_port,
 		flags |= OFDPA_OP_FLAG_REFRESH;
 	}
 
+	if (found && removing)
+		kfree(found);
+
 	return ofdpa_port_fdb_learn(ofdpa_port, flags, addr, vlan_id);
 }
 
-- 
2.43.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help