Skip to contentSkip to conversation

octeontx2-af: Fix rvu_mbox_init return path

PATCH Applied Subbaraya Sundeep 3 participants 5 messages Jun 18, 2025 – Jun 21, 2025

Subsystems (3)
lore
Share & tools
lore

Subbaraya Sundeep

author maintainer
#0 lore raw

PATCH 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.

Fixes e53ee4acb220 ("octeontx2-af: CN20k basic mbox operations and structures")
---
 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
index bfee71f4..7e538ee 100644
@@ -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
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Subbaraya Sundeep

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.

Fixes e53ee4acb220 ("octeontx2-af: CN20k basic mbox operations and structures")

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;
	}

...

author maintainer
#2 lore raw
Quoted 10 lines · Simon Horman
Quoted 8 lines · Subbaraya Sundeep

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.

Fixes e53ee4acb220 ("octeontx2-af: CN20k basic mbox operations and structures")
Quoted 6 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_regions does 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;
	}

...

reviewer
#3 lore raw
Quoted 13 lines · Subbaraya Sundeep
Quoted 12 lines · Simon Horman
Quoted 8 lines · Subbaraya Sundeep

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.

Fixes e53ee4acb220 ("octeontx2-af: CN20k basic mbox operations and structures")
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_regions does 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.

#4 lore raw
In reply to Subbaraya Sundeep
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_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.

Fixes e53ee4acb220 ("octeontx2-af: CN20k basic mbox operations and structures")

[...]

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