octeontx2-af: Fix rvu_mbox_init return path
Subbaraya Sundeep
maintainerPATCH 1/1 octeontx2-af: Fix rvu_mbox_init return path
rvu_mbox_init function makes use of error path for freeing memory which are local to the function in both success and failure conditions. This is unusual hence fix it by returning zero on success. With new cn20k code this is freeing valid memory in success case also.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +5 -1
@@ -2573,7 +2573,11 @@ static int rvu_mbox_init(struct rvu *rvu, struct mbox_wq_info *mw, mwork->rvu = rvu;INIT_WORK (&mwork->work, mbox_up_handler); } - goto free_regions; + +kfree (mbox_regions); +bitmap_free (pf_bmap); + +return 0 ; exit:destroy_workqueue (mw->mbox_wq);
Signature · 1 line
2.7.4
Quoted 8 lines · Subbaraya Sundeep
rvu_mbox_initfunction makes use of error path for freeing memory which are local to the function in both success and failure conditions. This is unusual hence fix it by returning zero on success. With new cn20k code this is freeing valid memory in success case also.Fixes e53ee4acb220 ("octeontx2-af: CN20k basic mbox operations and structures")Signed-off-by Subbaraya Sundeep <[email protected]>
Although I don't think the problem is introduced by this patch with it applied Smatch notices that the following code, around line 2528, which jumps to free_regions does so with err uninitialised. This is a problem because the jump will result in the function returning err.
switch (type) {
case TYPE_AFPF
...
default:
goto free_regions;
}...
Subbaraya Sundeep
maintainerQuoted 10 lines · Simon Horman
Quoted 8 lines · Subbaraya Sundeep
rvu_mbox_initfunction makes use of error path for freeing memory which are local to the function in both success and failure conditions. This is unusual hence fix it by returning zero on success. With new cn20k code this is freeing valid memory in success case also.Fixes e53ee4acb220 ("octeontx2-af: CN20k basic mbox operations and structures")Signed-off-by Subbaraya Sundeep <[email protected]>
Quoted 6 lines
Reviewed-by Simon Horman <[email protected]>Although I don't think the problem is introduced by this patch with it applied Smatch notices that the following code, around line 2528, which jumps to
free_regionsdoes so with err uninitialised. This is a problem because the jump will result in the function returning err.
Thanks Simon for review. I will send fix for Smatch error in separate patch later.
Sundeep
Quoted 10 lines
switch (type) { case TYPE_AFPF ... default: goto free_regions; }...
Simon Horman
reviewerQuoted 13 lines · Subbaraya Sundeep
Quoted 12 lines · Simon Horman
Quoted 8 lines · Subbaraya Sundeep
rvu_mbox_initfunction makes use of error path for freeing memory which are local to the function in both success and failure conditions. This is unusual hence fix it by returning zero on success. With new cn20k code this is freeing valid memory in success case also.Fixes e53ee4acb220 ("octeontx2-af: CN20k basic mbox operations and structures")Signed-off-by Subbaraya Sundeep <[email protected]>Reviewed-by Simon Horman <[email protected]>
Quoted 7 lines
Quoted 4 lines
Although I don't think the problem is introduced by this patch with it applied Smatch notices that the following code, around line 2528, which jumps to
free_regionsdoes so with err uninitialised. This is a problem because the jump will result in the function returning err.Thanks Simon for review. I will send fix for Smatch error in separate patch later.
Excellent, thanks.
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 10 lines · On Wed, 18 Jun 2025 19:27:16 +0530 you wrote:
rvu_mbox_initfunction makes use of error path for freeing memory which are local to the function in both success and failure conditions. This is unusual hence fix it by returning zero on success. With new cn20k code this is freeing valid memory in success case also.Fixes e53ee4acb220 ("octeontx2-af: CN20k basic mbox operations and structures")Signed-off-by Subbaraya Sundeep <[email protected]>[...]
Here is the summary with links:
- [net-next] octeontx2-af: Fix rvu_mbox_init return path
https://git.kernel.org/netdev/net-next/c/0289c51f889e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html