diff mbox series

[net] octeontx2-af: fix the double free in rvu_npc_freemem()

Message ID 20240424022724.144587-1-suhui@nfschina.com (mailing list archive)
State Accepted
Commit 6e965eba43e9724f3e603d7b7cc83e53b23d155e
Delegated to: Netdev Maintainers
Headers show
Series [net] octeontx2-af: fix the double free in rvu_npc_freemem() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 16 of 16 maintainers
netdev/build_clang success Errors and warnings before: 937 this patch: 937
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 937 this patch: 937
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-24--15-00 (tests: 995)

Commit Message

Su Hui April 24, 2024, 2:27 a.m. UTC
Clang static checker(scan-build) warning:
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c:line 2184, column 2
Attempt to free released memory.

npc_mcam_rsrcs_deinit() has released 'mcam->counters.bmap'. Deleted this
redundant kfree() to fix this double free problem.

Fixes: dd7842878633 ("octeontx2-af: Add new devlink param to configure maximum usable NIX block LFs")
Signed-off-by: Su Hui <suhui@nfschina.com>
---
 drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Geethasowjanya Akula April 24, 2024, 4:05 a.m. UTC | #1
> -----Original Message-----
> From: Su Hui <suhui@nfschina.com>
> Sent: Wednesday, April 24, 2024 7:57 AM
> To: Sunil Kovvuri Goutham <sgoutham@marvell.com>; Linu Cherian
> <lcherian@marvell.com>; Geethasowjanya Akula <gakula@marvell.com>;
> Jerin Jacob <jerinj@marvell.com>; Hariprasad Kelam
> <hkelam@marvell.com>; Subbaraya Sundeep Bhatta
> <sbhatta@marvell.com>; davem@davemloft.net; edumazet@google.com;
> kuba@kernel.org; pabeni@redhat.com; nathan@kernel.org;
> ndesaulniers@google.com; morbo@google.com; justinstitt@google.com
> Cc: Su Hui <suhui@nfschina.com>; Suman Ghosh <sumang@marvell.com>;
> netdev@vger.kernel.org; linux-kernel@vger.kernel.org; llvm@lists.linux.dev;
> kernel-janitors@vger.kernel.org
> Subject: [EXTERNAL] [PATCH net] octeontx2-af: fix the double free in
> rvu_npc_freemem()
> ----------------------------------------------------------------------
> Clang static checker(scan-build) warning:
> drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c:line 2184, column 2
> Attempt to free released memory.
> 
> npc_mcam_rsrcs_deinit() has released 'mcam->counters.bmap'. Deleted this
> redundant kfree() to fix this double free problem.
> 
> Fixes: dd7842878633 ("octeontx2-af: Add new devlink param to configure
> maximum usable NIX block LFs")
> Signed-off-by: Su Hui <suhui@nfschina.com>
> ---
>  drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> index be709f83f331..e8b73b9d75e3 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> @@ -2181,7 +2181,6 @@ void rvu_npc_freemem(struct rvu *rvu)
> 
>  	kfree(pkind->rsrc.bmap);
>  	npc_mcam_rsrcs_deinit(rvu);
> -	kfree(mcam->counters.bmap);
>  	if (rvu->kpu_prfl_addr)
>  		iounmap(rvu->kpu_prfl_addr);
>  	else
> --
> 2.30.2
Reviewed-by: Geetha sowjanya <gakula@marvell.com>
Kalesh Anakkur Purayil April 24, 2024, 4:05 a.m. UTC | #2
On Wed, Apr 24, 2024 at 7:58 AM Su Hui <suhui@nfschina.com> wrote:
>
> Clang static checker(scan-build) warning:
> drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c:line 2184, column 2
> Attempt to free released memory.
>
> npc_mcam_rsrcs_deinit() has released 'mcam->counters.bmap'. Deleted this
> redundant kfree() to fix this double free problem.
>
> Fixes: dd7842878633 ("octeontx2-af: Add new devlink param to configure maximum usable NIX block LFs")
> Signed-off-by: Su Hui <suhui@nfschina.com>

LGTM
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> ---
>  drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> index be709f83f331..e8b73b9d75e3 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> @@ -2181,7 +2181,6 @@ void rvu_npc_freemem(struct rvu *rvu)
>
>         kfree(pkind->rsrc.bmap);
>         npc_mcam_rsrcs_deinit(rvu);
> -       kfree(mcam->counters.bmap);
>         if (rvu->kpu_prfl_addr)
>                 iounmap(rvu->kpu_prfl_addr);
>         else
> --
> 2.30.2
>
>
Hariprasad Kelam April 24, 2024, 4:57 a.m. UTC | #3
> On Wed, Apr 24, 2024 at 7:58 AM Su Hui <suhui@nfschina.com> wrote:
> >
> > Clang static checker(scan-build) warning:
> > drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c:line 2184, column 2
> > Attempt to free released memory.
> >
> > npc_mcam_rsrcs_deinit() has released 'mcam->counters.bmap'. Deleted
> this
> > redundant kfree() to fix this double free problem.
> >
> > Fixes: dd7842878633 ("octeontx2-af: Add new devlink param to configure
> maximum usable NIX block LFs")
> > Signed-off-by: Su Hui <suhui@nfschina.com>

Reviewed-by: Hariprasad Kelam <hkelam@marvell.com>
> 
> LGTM
> Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> > ---
> >  drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> > index be709f83f331..e8b73b9d75e3 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
> > @@ -2181,7 +2181,6 @@ void rvu_npc_freemem(struct rvu *rvu)
> >
> >         kfree(pkind->rsrc.bmap);
> >         npc_mcam_rsrcs_deinit(rvu);
> > -       kfree(mcam->counters.bmap);
> >         if (rvu->kpu_prfl_addr)
> >                 iounmap(rvu->kpu_prfl_addr);
> >         else
> > --
> > 2.30.2
> >
> >
> 
> 
> --
> Regards,
> Kalesh A P
Markus Elfring April 24, 2024, 7:56 a.m. UTC | #4
> npc_mcam_rsrcs_deinit() has released 'mcam->counters.bmap'. Deleted this
> redundant kfree() to fix this double free problem.
…

Can a wording variant (like the following) be a bit nicer?

   The object “mcam->counters.bmap” was released during the execution of
   the function “npc_mcam_rsrcs_deinit”.
   Delete a subsequent kfree() call to fix this double free problem.


Regards,
Markus
patchwork-bot+netdevbpf@kernel.org April 25, 2024, 3:40 p.m. UTC | #5
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 24 Apr 2024 10:27:25 +0800 you wrote:
> Clang static checker(scan-build) warning:
> drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c:line 2184, column 2
> Attempt to free released memory.
> 
> npc_mcam_rsrcs_deinit() has released 'mcam->counters.bmap'. Deleted this
> redundant kfree() to fix this double free problem.
> 
> [...]

Here is the summary with links:
  - [net] octeontx2-af: fix the double free in rvu_npc_freemem()
    https://git.kernel.org/netdev/net/c/6e965eba43e9

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
index be709f83f331..e8b73b9d75e3 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
@@ -2181,7 +2181,6 @@  void rvu_npc_freemem(struct rvu *rvu)
 
 	kfree(pkind->rsrc.bmap);
 	npc_mcam_rsrcs_deinit(rvu);
-	kfree(mcam->counters.bmap);
 	if (rvu->kpu_prfl_addr)
 		iounmap(rvu->kpu_prfl_addr);
 	else