FAILED: patch "[PATCH] octeontx2-pf: avoid double free of pool->stack on AQ init" failed to apply to 5.15-stable tree
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 9b244c242bec48b37e82b89787afd6a4c43457e1
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026052845-shush-commuting-ee9c@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 9b244c242bec48b37e82b89787afd6a4c43457e1 Mon Sep 17 00:00:00 2001
From: Dawei Feng <[email protected]>
Date: Fri, 15 May 2026 23:18:26 +0800
Subject: [PATCH] octeontx2-pf: avoid double free of pool->stack on AQ init
failure
otx2_pool_aq_init() frees pool->stack when mailbox sync or retry allocation fails, but leaves the pointer unchanged. Later, otx2_sq_aura_pool_init() unwinds the partial setup through otx2_aura_pool_free(), which frees pool->stack again. The CN20K-specific cn20k_pool_aq_init() implementation has the same bug in
its corresponding error path.
Set pool->stack to NULL immediately after the local free so the shared cleanup path does not free the same stack again while cleaning up partially initialized pool state.
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 validation was not performed because reproducing this path requires OcteonTX2/CN20K hardware.
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +2 -0
@@ -619,11 +619,13 @@ static int cn20k_pool_aq_init(struct otx2_nic *pfvf, u16 pool_id, err =otx2_sync_mbox_msg (&pfvf->mbox);if (err) {qmem_free (pfvf->dev, pool->stack); + pool->stack =NULL ;return err; } aq =otx2_mbox_alloc_msg_npa_cn20k_aq_enq (&pfvf->mbox);if (!aq) {qmem_free (pfvf->dev, pool->stack); + pool->stack =NULL ;return -ENOMEM ; } }
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +2 -0
@@ -1482,11 +1482,13 @@ int otx2_pool_aq_init(struct otx2_nic *pfvf, u16 pool_id, err =otx2_sync_mbox_msg (&pfvf->mbox);if (err) {qmem_free (pfvf->dev, pool->stack); + pool->stack =NULL ;return err; } aq =otx2_mbox_alloc_msg_npa_aq_enq (&pfvf->mbox);if (!aq) {qmem_free (pfvf->dev, pool->stack); + pool->stack =NULL ;return -ENOMEM ; } }
Sasha Levin
maintainerPATCH 1/1 octeontx2-pf: avoid double free of pool->stack on AQ init failure
From: Dawei Feng <[email protected]>
[ Upstream commit 9b244c242bec48b37e82b89787afd6a4c43457e1 ]
otx2_pool_aq_init() frees pool->stack when mailbox sync or retry allocation fails, but leaves the pointer unchanged. Later, otx2_sq_aura_pool_init() unwinds the partial setup through otx2_aura_pool_free(), which frees pool->stack again. The CN20K-specific cn20k_pool_aq_init() implementation has the same bug in
its corresponding error path.
Set pool->stack to NULL immediately after the local free so the shared cleanup path does not free the same stack again while cleaning up partially initialized pool state.
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 validation was not performed because reproducing this path requires OcteonTX2/CN20K hardware.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +2 -0
@@ -1258,11 +1258,13 @@ static int otx2_pool_init(struct otx2_nic *pfvf, u16 pool_id, err =otx2_sync_mbox_msg (&pfvf->mbox);if (err) {qmem_free (pfvf->dev, pool->stack); + pool->stack =NULL ;return err; } aq =otx2_mbox_alloc_msg_npa_aq_enq (&pfvf->mbox);if (!aq) {qmem_free (pfvf->dev, pool->stack); + pool->stack =NULL ;return -ENOMEM ; } }
Signature · 1 line
2.53.0