Netdev List
 help / color / mirror / Atom feed
* [PATCH net] qed: fix double free in qed_cxt_tables_alloc()
@ 2026-05-20  7:03 Dawei Feng
  2026-05-21 15:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Dawei Feng @ 2026-05-20  7:03 UTC (permalink / raw)
  To: kuba
  Cc: andrew+netdev, davem, edumazet, pabeni, kees, Ariel.Elior,
	Yuval.Mintz, netdev, linux-kernel, jianhao.xu, Dawei Feng, stable,
	Zilin Guan

If one of the later PF or VF CID bitmap allocations fails,
qed_cid_map_alloc() jumps to cid_map_fail and frees the previously
allocated CID bitmaps before returning an error. qed_cxt_tables_alloc()
then calls qed_cxt_mngr_free(), which invokes qed_cid_map_free()
again.

Fix this by setting each CID bitmap pointer to NULL after bitmap_free()
to avoid double free.

The bug was first flagged by an experimental analysis tool we are
developing for kernel memory-management bugs while analyzing
v6.13-rc1. The tool is still under development and is not yet publicly
available. Manual inspection confirms that the bug is still
present in v7.1-rc3.

Runtime reproduction was not attempted because exercising the failing
allocation path requires device-specific setup.

Fixes: fe56b9e6a8d9 ("qed: Add module with basic common support")
Cc: stable@vger.kernel.org
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Signed-off-by: Dawei Feng <dawei.feng@seu.edu.cn>
---
 drivers/net/ethernet/qlogic/qed/qed_cxt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_cxt.c b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
index 9861daa82d9e..b70262e70baf 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_cxt.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_cxt.c
@@ -1036,11 +1036,13 @@ static void qed_cid_map_free(struct qed_hwfn *p_hwfn)
 
 	for (type = 0; type < MAX_CONN_TYPES; type++) {
 		bitmap_free(p_mngr->acquired[type].cid_map);
+		p_mngr->acquired[type].cid_map = NULL;
 		p_mngr->acquired[type].max_count = 0;
 		p_mngr->acquired[type].start_cid = 0;
 
 		for (vf = 0; vf < MAX_NUM_VFS; vf++) {
 			bitmap_free(p_mngr->acquired_vf[type][vf].cid_map);
+			p_mngr->acquired_vf[type][vf].cid_map = NULL;
 			p_mngr->acquired_vf[type][vf].max_count = 0;
 			p_mngr->acquired_vf[type][vf].start_cid = 0;
 		}
-- 
2.34.1


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

* Re: [PATCH net] qed: fix double free in qed_cxt_tables_alloc()
  2026-05-20  7:03 [PATCH net] qed: fix double free in qed_cxt_tables_alloc() Dawei Feng
@ 2026-05-21 15:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-05-21 15:20 UTC (permalink / raw)
  To: Dawei Feng
  Cc: kuba, andrew+netdev, davem, edumazet, pabeni, kees, Ariel.Elior,
	Yuval.Mintz, netdev, linux-kernel, jianhao.xu, stable, zilin

Hello:

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

On Wed, 20 May 2026 15:03:23 +0800 you wrote:
> If one of the later PF or VF CID bitmap allocations fails,
> qed_cid_map_alloc() jumps to cid_map_fail and frees the previously
> allocated CID bitmaps before returning an error. qed_cxt_tables_alloc()
> then calls qed_cxt_mngr_free(), which invokes qed_cid_map_free()
> again.
> 
> Fix this by setting each CID bitmap pointer to NULL after bitmap_free()
> to avoid double free.
> 
> [...]

Here is the summary with links:
  - [net] qed: fix double free in qed_cxt_tables_alloc()
    https://git.kernel.org/netdev/net/c/2bccfb8476ca

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-05-21 15:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-20  7:03 [PATCH net] qed: fix double free in qed_cxt_tables_alloc() Dawei Feng
2026-05-21 15:20 ` patchwork-bot+netdevbpf

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