octeontx2-af: CGX: fix bitmap leaks
v2 cover octeontx2-af: CGX: fix bitmap leaks
Patch 1 fixes the RX/TX flow-control bitmap leaks in cgx_lmac_exit(). The leak was introduced in commit e740003874ed ("octeontx2-af: Flow control resource management").
Patch 2 converts the existing kfree() for mac_to_index_bmap to rvu_free_bitmap() for consistency with the alloc/free API pairing.
Changes in v2:
- Update patch 1 to use rvu_free_bitmap() instead of open-coding kfree()
- Add patch 2 to keep the alloc/free API pairing consistent
Bo Sun (2):
octeontx2-af: CGX: fix bitmap leaks
octeontx2-af: CGX: replace kfree() with rvu_free_bitmap()
drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
PATCH v2 1/2 octeontx2-af: CGX: fix bitmap leaks
The RX/TX flow-control bitmaps (rx_fc_pfvf_bmap and tx_fc_pfvf_bmap) are allocated by cgx_lmac_init() but never freed in cgx_lmac_exit(). Unbinding and rebinding the driver therefore triggers kmemleak:
unreferenced object (size 16):
backtrace:
rvu_alloc_bitmap
cgx_probe
Free both bitmaps during teardown.
--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +2 -0
@@ -1823,6 +1823,8 @@ static int cgx_lmac_exit(struct cgx *cgx) cgx->mac_ops->mac_pause_frm_config (cgx, lmac->lmac_id, false);cgx_configure_interrupt (cgx, lmac, lmac->lmac_id, true);kfree (lmac->mac_to_index_bmap.bmap); +rvu_free_bitmap (&lmac->rx_fc_pfvf_bmap); +rvu_free_bitmap (&lmac->tx_fc_pfvf_bmap);kfree (lmac->name);kfree (lmac); }
Quoted 23 lines · Bo Sun
The RX/TX flow-control bitmaps (
rx_fc_pfvf_bmapandtx_fc_pfvf_bmap) are allocated bycgx_lmac_init()but never freed incgx_lmac_exit(). Unbinding and rebinding the driver therefore triggers kmemleak:unreferenced object (size 16):
backtrace:
rvu_alloc_bitmap
cgx_probeFree both bitmaps during teardown.
Fixes e740003874ed ("octeontx2-af: Flow control resource management")Signed-off-by Bo Sun <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 2 ++ 1 file changed, 2 insertions(+)drivers/net/ethernet/marvell/octeontx2/af/cgx.c +0
-0
drivers/net/ethernet/marvell/octeontx2/af/cgx.c static int cgx_lmac_exit(struct cgx *cgx) · line 1830
Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +2
-0@@ -1823,6 +1823,8 @@ static int cgx_lmac_exit(struct cgx *cgx) cgx->mac_ops->mac_pause_frm_config (cgx, lmac->lmac_id, false);cgx_configure_interrupt (cgx, lmac, lmac->lmac_id, true);kfree (lmac->mac_to_index_bmap.bmap); +rvu_free_bitmap (&lmac->rx_fc_pfvf_bmap); +rvu_free_bitmap (&lmac->tx_fc_pfvf_bmap);kfree (lmac->name);kfree (lmac); }
Quoted 23 lines · Bo Sun
The RX/TX flow-control bitmaps (
rx_fc_pfvf_bmapandtx_fc_pfvf_bmap) are allocated bycgx_lmac_init()but never freed incgx_lmac_exit(). Unbinding and rebinding the driver therefore triggers kmemleak:unreferenced object (size 16):
backtrace:
rvu_alloc_bitmap
cgx_probeFree both bitmaps during teardown.
Fixes e740003874ed ("octeontx2-af: Flow control resource management")Signed-off-by Bo Sun <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 2 ++ 1 file changed, 2 insertions(+)drivers/net/ethernet/marvell/octeontx2/af/cgx.c +0
-0
drivers/net/ethernet/marvell/octeontx2/af/cgx.c static int cgx_lmac_exit(struct cgx *cgx) · line 1827
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +2
-0@@ -1823,6 +1823,8 @@ static int cgx_lmac_exit(struct cgx *cgx) cgx->mac_ops->mac_pause_frm_config (cgx, lmac->lmac_id, false);cgx_configure_interrupt (cgx, lmac, lmac->lmac_id, true);kfree (lmac->mac_to_index_bmap.bmap); +rvu_free_bitmap (&lmac->rx_fc_pfvf_bmap); +rvu_free_bitmap (&lmac->tx_fc_pfvf_bmap);
PATCH v2 2/2 octeontx2-af: CGX: replace kfree() with rvu_free_bitmap()
In reply to Bo Sunmac_to_index_bmap is allocated with rvu_alloc_bitmap(), so free it with rvu_free_bitmap() instead of open-coding kfree(.bmap) to keep the alloc/free API pairing consistent.
--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +1 -1
@@ -1822,7 +1822,7 @@ static int cgx_lmac_exit(struct cgx *cgx)continue ; cgx->mac_ops->mac_pause_frm_config (cgx, lmac->lmac_id, false);cgx_configure_interrupt (cgx, lmac, lmac->lmac_id, true); -kfree (lmac->mac_to_index_bmap.bmap); +rvu_free_bitmap (&lmac->mac_to_index_bmap);rvu_free_bitmap (&lmac->rx_fc_pfvf_bmap);rvu_free_bitmap (&lmac->tx_fc_pfvf_bmap);kfree (lmac->name);
Re: [PATCH net v2 2/2] octeontx2-af: CGX: replace kfree() with rvu_free_bitmap()
Quoted 14 lines · Bo Sun
mac_to_index_bmapis allocated withrvu_alloc_bitmap(), so free it withrvu_free_bitmap()instead of open-coding kfree(.bmap) to keep the alloc/free API pairing consistent.Signed-off-by Bo Sun <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/marvell/octeontx2/af/cgx.c +0
-0
drivers/net/ethernet/marvell/octeontx2/af/cgx.c static int cgx_lmac_exit(struct cgx *cgx) · line 1828
Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +1
-1@@ -1822,7 +1822,7 @@ static int cgx_lmac_exit(struct cgx *cgx)continue ; cgx->mac_ops->mac_pause_frm_config (cgx, lmac->lmac_id, false);cgx_configure_interrupt (cgx, lmac, lmac->lmac_id, true); -kfree (lmac->mac_to_index_bmap.bmap); +rvu_free_bitmap (&lmac->mac_to_index_bmap);rvu_free_bitmap (&lmac->rx_fc_pfvf_bmap);rvu_free_bitmap (&lmac->tx_fc_pfvf_bmap);kfree (lmac->name);
The code LGTM, but as Jakub metioned in v1, the cleanup should be a separate patch targeting net-next.
On respin you can add:
Re: [PATCH net v2 2/2] octeontx2-af: CGX: replace kfree() with rvu_free_bitmap()
Quoted 27 lines · Vadim Fedorenko
Quoted 14 lines · Bo Sun
mac_to_index_bmapis allocated withrvu_alloc_bitmap(), so free it withrvu_free_bitmap()instead of open-coding kfree(.bmap) to keep the alloc/free API pairing consistent.Signed-off-by Bo Sun <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/marvell/octeontx2/af/cgx.c +0
-0drivers/net/ethernet/marvell/octeontx2/af/cgx.c static int cgx_lmac_exit(struct cgx *cgx) · line 1828
Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +1
-1@@ -1822,7 +1822,7 @@ static int cgx_lmac_exit(struct cgx *cgx)continue ; cgx->mac_ops->mac_pause_frm_config (cgx, lmac->lmac_id, false);cgx_configure_interrupt (cgx, lmac, lmac->lmac_id, true); -kfree (lmac->mac_to_index_bmap.bmap); +rvu_free_bitmap (&lmac->mac_to_index_bmap);rvu_free_bitmap (&lmac->rx_fc_pfvf_bmap);rvu_free_bitmap (&lmac->tx_fc_pfvf_bmap);kfree (lmac->name);The code LGTM, but as Jakub metioned in v1, the cleanup should be a separate patch targeting net-next.
Quoted 2 lines
On respin you can add:
Reviewed-by Vadim Fedorenko <[email protected]>
Thanks. Will send the respin targeting net-next once it reopens.
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Fri, 6 Feb 2026 21:09:23 +0800 you wrote:
Patch 1 fixes the RX/TX flow-control bitmap leaks in
cgx_lmac_exit(). The leak was introduced in commite740003874ed("octeontx2-af: Flow control resource management").
Patch 2 converts the existingkfree()formac_to_index_bmaptorvu_free_bitmap()for consistency with the alloc/free API pairing.Changes in v2:
- Update patch 1 to uservu_free_bitmap()instead of open-codingkfree()
- Add patch 2 to keep the alloc/free API pairing consistent[...]
Here is the summary with links:
- [net,v2,1/2] octeontx2-af: CGX: fix bitmap leaks
https://git.kernel.org/netdev/net/c/3def995c4ede
- [net,v2,2/2] octeontx2-af: CGX: replace kfree() with rvu_free_bitmap() (no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html