Skip to contentSkip to conversation

octeontx2-af: CGX: fix bitmap leaks

PATCH In review Bo Sun 4 participants 8 messages Feb 6 – Feb 11

Subsystems (4)
lore
Share & tools
lore

Bo Sun

author
#0 lore raw

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(-)
author
#1 lore raw

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.

Fixes e740003874ed ("octeontx2-af: Flow control resource management")
---
 drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +2 -0
index 42044cd810b1..fd4792e432bf 100644
@@ -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);
 	}
Reviewed-by on v2 1/2
#2 lore raw
Quoted 23 lines · Bo Sun

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.

Fixes e740003874ed ("octeontx2-af: Flow control resource management")
---
  drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +0 -0
index 42044cd810b1..fd4792e432bf 100644

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);
  	}
Reviewed-by on v2 1/2
#3 lore raw
In reply to Bo Sun
Quoted 23 lines · Bo Sun

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.

Fixes e740003874ed ("octeontx2-af: Flow control resource management")
---
  drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +0 -0
index 42044cd810b1..fd4792e432bf 100644

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);
author
#4 lore raw

PATCH v2 2/2 octeontx2-af: CGX: replace kfree() with rvu_free_bitmap()

In reply to Bo Sun

mac_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
index fd4792e432bf..29f5def796ba 100644
@@ -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);
Reviewed-by on v2 2/2
#5 lore raw

Re: [PATCH net v2 2/2] octeontx2-af: CGX: replace kfree() with rvu_free_bitmap()

Quoted 14 lines · Bo Sun

mac_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 +0 -0
index fd4792e432bf..29f5def796ba 100644

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:

author
#6 lore raw

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_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 +0 -0
index fd4792e432bf..29f5def796ba 100644

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.

Quoted 2 lines

On respin you can add:

Thanks. Will send the respin targeting net-next once it reopens.

#7 lore raw
In reply to Bo Sun
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 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

[...]

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