net: mana: Fix EQ leak in mana_remove on NULL port
PATCH 1/1 net: mana: Fix EQ leak in mana_remove on NULL port
From: Erni Sri Satya Vennela <[email protected]>
[ Upstream commit 65267c9c4f28199985505977bc2c628c82fc50ef ]
In mana_remove(), when a NULL port is encountered in the port iteration loop, 'goto out' skips the mana_destroy_eq(ac) call, leaking the event queues allocated earlier by mana_create_eq().
This can happen when mana_probe_port() fails for port 0, leaving ac->ports[0] as NULL. On driver unload or error cleanup, mana_remove() hits the NULL entry and jumps past mana_destroy_eq().
Change 'goto out' to 'break' so the for-loop exits normally and mana_destroy_eq() is always reached. Remove the now-unreferenced out:
label.
[ hmahfooz: resolve conflict in mana_remove() due to missing commit
3b194343c250 ("net: mana: Implement ndo_tx_timeout and serialize queue resets per port.") ]
--- drivers/net/ethernet/microsoft/mana/mana_en.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/microsoft/mana/mana_en.c +2 -2
@@ -3442,7 +3442,7 @@ void mana_remove(struct gdma_dev *gd, bool suspending)if (!ndev) {if (i ==0 )dev_err (dev,"No net device to remove\n" ); - goto out; +break ; }/* All cleanup actions should stay after rtnl_lock(), otherwise
@@ -3470,7 +3470,7 @@ void mana_remove(struct gdma_dev *gd, bool suspending) }mana_destroy_eq (ac); -out: +mana_gd_deregister_device (gd);if (suspending)
Signature · 1 line
2.55.0
Quoted 1 line · Hamza Mahfooz
[ Upstream commit
65267c9c4f28199985505977bc2c628c82fc50ef]
Queued for 6.12 and 6.6, thanks - 6.12 is missing it too and your conflict resolution applies there unchanged, so it gets the same patch.
Signature · 2 lines
Thanks, Sasha