rocker: Fix memory leak in ofdpa_port_fdb()

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.

Cc: <stable+noautosel@kernel.org> # rocker is a test harness, it's never loaded on production systems
Signed-off-by: Ziran Zhang <zhangcoder@yeah.net>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://patch.msgid.link/20260616013245.7098-1-zhangcoder@yeah.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Ziran Zhang 2026-06-16 09:32:45 +08:00 committed by Jakub Kicinski
parent 56abdaebbf
commit 53442aad1d

View File

@ -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);
}