Subject: Re: [net-next PATCH] octeontx2-af: Add new devlink param to configure maximum usable NIX block LFs

From: Simon Horman <[email-masked]>
Date: Mon, 18 Dec 2023 16:23:16 +0000

On Fri, Dec 15, 2023 at 05:31:49PM +0530, Suman Ghosh wrote:
> On some silicon variants the number of available CAM entries are
> less. Reserving one entry for each NIX-LF for default DMAC based pkt
> forwarding rules will reduce the number of available CAM entries
> further. Hence add configurability via devlink to set maximum number of
> NIX-LFs needed which inturn frees up some CAM entries.
> 
> Signed-off-by: Suman Ghosh <[email-masked]>

...

> @@ -1964,8 +1977,21 @@ static int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr)
>  
>  	return 0;
>  
> -free_mem:
> +free_cntr_refcnt:
> +	kfree(mcam->cntr_refcnt);
> +free_entry_cntr_map:
> +	kfree(mcam->entry2cntr_map);
> +free_cntr_map:
> +	kfree(mcam->cntr2pfvf_map);
> +free_cntr_bmap:
> +	kfree(mcam->counters.bmap);
> +free_entry_map:
> +	kfree(mcam->entry2pfvf_map);
> +free_bmap_reverse:
> +	kfree(mcam->bmap_reverse);
> +free_bmap:
>  	kfree(mcam->counters.bmap);
> +
>  	return -ENOMEM;
>  }
>  

Hi Suman,

I realise that this patch has been accepted.
But I believe there is a double-free problem above
as mcam->counters.bmap may be freed twice.
And mcam->bmap seems to be leaked.

Perhaps the last part of the unwind ladder should be:

free_bmap:
	kfree(mcam->bmap);

Double-free flagged by Smatch and Coccinelle.