public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 1/1] octeontx2-af: CGX: fix bitmap leaks
       [not found] <20251020143112.357819-1-bo@mboxify.com>
@ 2025-10-20 14:31 ` Bo Sun
  2025-10-20 15:45   ` Alexander Lobakin
  2025-10-23  1:22   ` Jakub Kicinski
  0 siblings, 2 replies; 6+ messages in thread
From: Bo Sun @ 2025-10-20 14:31 UTC (permalink / raw)
  To: kuba, pabeni
  Cc: sgoutham, lcherian, gakula, jerinj, hkelam, sbhatta,
	andrew+netdev, davem, edumazet, netdev, linux-kernel, Bo Sun,
	stable

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")
Cc: stable@vger.kernel.org
Signed-off-by: Bo Sun <bo@mboxify.com>
---
 drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
index ec0e11c77cbf..f56e6782c4de 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
@@ -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);
+		kfree(lmac->rx_fc_pfvf_bmap.bmap);
+		kfree(lmac->tx_fc_pfvf_bmap.bmap);
 		kfree(lmac->name);
 		kfree(lmac);
 	}

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/1] octeontx2-af: CGX: fix bitmap leaks
  2025-10-20 14:31 ` [PATCH net 1/1] octeontx2-af: CGX: fix bitmap leaks Bo Sun
@ 2025-10-20 15:45   ` Alexander Lobakin
  2025-10-23  1:22   ` Jakub Kicinski
  1 sibling, 0 replies; 6+ messages in thread
From: Alexander Lobakin @ 2025-10-20 15:45 UTC (permalink / raw)
  To: Bo Sun
  Cc: kuba, pabeni, sgoutham, lcherian, gakula, jerinj, hkelam, sbhatta,
	andrew+netdev, davem, edumazet, netdev, linux-kernel, stable

From: Bo Sun <bo@mboxify.com>
Date: Mon, 20 Oct 2025 22:31:12 +0800

> 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")
> Cc: stable@vger.kernel.org
> Signed-off-by: Bo Sun <bo@mboxify.com>

Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com>

> ---
>  drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
> index ec0e11c77cbf..f56e6782c4de 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
> @@ -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);
> +		kfree(lmac->rx_fc_pfvf_bmap.bmap);
> +		kfree(lmac->tx_fc_pfvf_bmap.bmap);
>  		kfree(lmac->name);
>  		kfree(lmac);
>  	}

Thanks,
Olek

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/1] octeontx2-af: CGX: fix bitmap leaks
  2025-10-20 14:31 ` [PATCH net 1/1] octeontx2-af: CGX: fix bitmap leaks Bo Sun
  2025-10-20 15:45   ` Alexander Lobakin
@ 2025-10-23  1:22   ` Jakub Kicinski
  2026-02-05 13:35     ` Bo Sun
  1 sibling, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2025-10-23  1:22 UTC (permalink / raw)
  To: Bo Sun
  Cc: pabeni, sgoutham, lcherian, gakula, jerinj, hkelam, sbhatta,
	andrew+netdev, davem, edumazet, netdev, linux-kernel, stable

On Mon, 20 Oct 2025 22:31:12 +0800 Bo Sun wrote:
> 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")
> Cc: stable@vger.kernel.org
> Signed-off-by: Bo Sun <bo@mboxify.com>

Looks like rvu_free_bitmap() exists. We should probably use it?

> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
> index ec0e11c77cbf..f56e6782c4de 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
> @@ -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);
> +		kfree(lmac->rx_fc_pfvf_bmap.bmap);
> +		kfree(lmac->tx_fc_pfvf_bmap.bmap);
>  		kfree(lmac->name);
>  		kfree(lmac);
>  	}
-- 
pw-bot: cr


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/1] octeontx2-af: CGX: fix bitmap leaks
  2025-10-23  1:22   ` Jakub Kicinski
@ 2026-02-05 13:35     ` Bo Sun
  2026-02-05 15:48       ` Jakub Kicinski
  0 siblings, 1 reply; 6+ messages in thread
From: Bo Sun @ 2026-02-05 13:35 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: pabeni, sgoutham, lcherian, gakula, jerinj, hkelam, sbhatta,
	andrew+netdev, davem, edumazet, netdev, linux-kernel, stable

On 10/23/2025 9:22 AM, Jakub Kicinski wrote:
> On Mon, 20 Oct 2025 22:31:12 +0800 Bo Sun wrote:
>> 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")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Bo Sun <bo@mboxify.com>
> 
> Looks like rvu_free_bitmap() exists. We should probably use it?

Apologies for the late reply.
You're right that rvu_free_bitmap() exists. I stayed with direct kfree()
for consistency with the existing code in cgx_lmac_exit(), because which
already uses kfree(lmac->mac_to_index_bmap.bmap).

That said, I'm OK with either way:
1. Keep kfree() to match the existing pattern in this function
2. Switch all three bitmap frees (including mac_to_index_bmap) to use
rvu_free_bitmap() for consistency with the alloc/free API pairing

What's your preference?

Thanks,
Bo

> 
>> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
>> index ec0e11c77cbf..f56e6782c4de 100644
>> --- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
>> +++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
>> @@ -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);
>> +		kfree(lmac->rx_fc_pfvf_bmap.bmap);
>> +		kfree(lmac->tx_fc_pfvf_bmap.bmap);
>>   		kfree(lmac->name);
>>   		kfree(lmac);
>>   	}


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/1] octeontx2-af: CGX: fix bitmap leaks
  2026-02-05 13:35     ` Bo Sun
@ 2026-02-05 15:48       ` Jakub Kicinski
  2026-02-06 10:09         ` bo
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2026-02-05 15:48 UTC (permalink / raw)
  To: Bo Sun
  Cc: pabeni, sgoutham, lcherian, gakula, jerinj, hkelam, sbhatta,
	andrew+netdev, davem, edumazet, netdev, linux-kernel, stable

On Thu, 5 Feb 2026 21:35:29 +0800 Bo Sun wrote:
> >> Fixes: e740003874ed ("octeontx2-af: Flow control resource management")
> >> Cc: stable@vger.kernel.org
> >> Signed-off-by: Bo Sun <bo@mboxify.com>  
> > 
> > Looks like rvu_free_bitmap() exists. We should probably use it?  
> 
> Apologies for the late reply.
> You're right that rvu_free_bitmap() exists. I stayed with direct kfree()
> for consistency with the existing code in cgx_lmac_exit(), because which
> already uses kfree(lmac->mac_to_index_bmap.bmap).
> 
> That said, I'm OK with either way:
> 1. Keep kfree() to match the existing pattern in this function
> 2. Switch all three bitmap frees (including mac_to_index_bmap) to use
> rvu_free_bitmap() for consistency with the alloc/free API pairing
> 
> What's your preference?

3. do what I implied, just use rvu_free_bitmap() in this single case
for the fix. Follow up separately with a patch to remaining sites if
any to convert from kfree() to rvu_free_bitmap(). We want the fix
itself to be small, the cleanup should be separate.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/1] octeontx2-af: CGX: fix bitmap leaks
  2026-02-05 15:48       ` Jakub Kicinski
@ 2026-02-06 10:09         ` bo
  0 siblings, 0 replies; 6+ messages in thread
From: bo @ 2026-02-06 10:09 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: pabeni, sgoutham, lcherian, gakula, jerinj, hkelam, sbhatta,
	andrew+netdev, davem, edumazet, netdev, linux-kernel, stable

On 2026-02-05 23:48, Jakub Kicinski wrote:
> On Thu, 5 Feb 2026 21:35:29 +0800 Bo Sun wrote:
>> >> Fixes: e740003874ed ("octeontx2-af: Flow control resource management")
>> >> Cc: stable@vger.kernel.org
>> >> Signed-off-by: Bo Sun <bo@mboxify.com>
>> >
>> > Looks like rvu_free_bitmap() exists. We should probably use it?
>> 
>> Apologies for the late reply.
>> You're right that rvu_free_bitmap() exists. I stayed with direct 
>> kfree()
>> for consistency with the existing code in cgx_lmac_exit(), because 
>> which
>> already uses kfree(lmac->mac_to_index_bmap.bmap).
>> 
>> That said, I'm OK with either way:
>> 1. Keep kfree() to match the existing pattern in this function
>> 2. Switch all three bitmap frees (including mac_to_index_bmap) to use
>> rvu_free_bitmap() for consistency with the alloc/free API pairing
>> 
>> What's your preference?
> 
> 3. do what I implied, just use rvu_free_bitmap() in this single case
> for the fix. Follow up separately with a patch to remaining sites if
> any to convert from kfree() to rvu_free_bitmap(). We want the fix
> itself to be small, the cleanup should be separate.

Thanks, I'll send v2.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-02-06 10:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20251020143112.357819-1-bo@mboxify.com>
2025-10-20 14:31 ` [PATCH net 1/1] octeontx2-af: CGX: fix bitmap leaks Bo Sun
2025-10-20 15:45   ` Alexander Lobakin
2025-10-23  1:22   ` Jakub Kicinski
2026-02-05 13:35     ` Bo Sun
2026-02-05 15:48       ` Jakub Kicinski
2026-02-06 10:09         ` bo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox