From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 378E53502B8; Sun, 7 Jun 2026 10:59:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780829995; cv=none; b=AsdsaTKuqAJtYy/zZP6IBqu+Jykx4dL7KEWrCllZxISwzwX/yrAHwvOWrmTAQHJhO6m+mTR77g68SbWyZrYSoSNGnTta+Zwgn4vMreWfrpBBpAcsTCqbxxBMjEQXkfimpGKFftEqOpFajELJ8ZloV2zOz02DRS1G0fCFTWjdxHE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780829995; c=relaxed/simple; bh=jkmQQi0Eg2j5QhOkti1QlqGdllSTcEKxF4xJuJxBSZQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LdMvpg3+DSv9lImFLaQt7NJwY7U5Mh2WSLYSC91a/E+z/4TvXLZAUxCWTQuFptIzUAGDa2w+KoJTUsbLlvhlaJSW01735mJXoLAtRDbbH9Zc4O4ApYQ6g0bsdA7nwLtpm84qi1JlJ8vI6SJZG5gljqbdN1V11gJeVozasX2/2aE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eLFeq4yQ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="eLFeq4yQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE2241F00893; Sun, 7 Jun 2026 10:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780829985; bh=J+T7BRFvvvtGELDtt+3S0LmT6s2xu+ViTdVtCXT9yjo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eLFeq4yQTxGsjN1evkf6Wne65DpvPru6v+qGATLeeE9F07QB9G0LWnCncP9fgfGKO FazTBufa2zVAFyIM9Ka1jnEuKB+mY34w3abP6dosS+J8TU8liGMiDv03AwYd2Yiit+ 79j0hdJ3tawzzgsH83NzanQj2pQ2Xhi064f/sUxM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zilin Guan , Dawei Feng , Simon Horman , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.18 297/315] octeontx2-pf: avoid double free of pool->stack on AQ init failure Date: Sun, 7 Jun 2026 12:01:24 +0200 Message-ID: <20260607095738.503020883@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095727.528828913@linuxfoundation.org> References: <20260607095727.528828913@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dawei Feng [ 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. Fixes: caa2da34fd25 ("octeontx2-pf: Initialize and config queues") Fixes: d322fbd17203 ("octeontx2-pf: Initialize cn20k specific aura and pool contexts") Cc: stable@vger.kernel.org Signed-off-by: Zilin Guan Signed-off-by: Dawei Feng Reviewed-by: Simon Horman Link: https://patch.msgid.link/20260515151826.1005397-1-dawei.feng@seu.edu.cn Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c @@ -1468,11 +1468,13 @@ int otx2_pool_init(struct otx2_nic *pfvf 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; } }