Article View: linux.kernel.netdev
Article #22933Re: [PATCH net] octeontx2-pf: QOS: Don't free SQ memory if disabling the SQ fails
From: netdev-bot+sashiko
Date: Thu, 26 Nov 2026 07:00
Date: Thu, 26 Nov 2026 07:00
181 lines
15066 bytes
15066 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 (1) · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] If otx2_qos_ctx_disable() fails, the new early return in
otx2_qos_disable_sq() (qos_sq.c:316-322) leaves all the queue state in…
- [Low] The commit message says otx2_free_hw_resources() frees the kept
memory 'after the SQ and NPA contexts of the whole LF have been…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
otx2_qos_sq_free_sqbs() (qos_sq.c:116-148), called on every successful…
--
octeontx2-pf: QOS: Don't free SQ memory if disabling the SQ fails
This patch makes otx2_qos_disable_sq() check the return value of
otx2_qos_ctx_disable(). If the AF mailbox request fails, it now logs an
error and returns without freeing the SQBs, the pool stack and the aura
flow-control buffer, which the hardware may still reference.
> If the disable fails, log an error and keep the memory: leaking it is
> safer than freeing memory the hardware may still access. If the queue
> is not set up again, otx2_free_hw_resources() frees it later with the
> other queues when the interface goes down, after the SQ and NPA
> contexts of the whole LF have been disabled.
[Severity: Low]
Is this ordering accurate? otx2_free_hw_resources() calls
otx2_free_sq_res(). That function frees the SQB pages of every queue,
QoS queues included, right after a best-effort SQ disable:
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c:otx2_free_sq_res() {
...
/* Disable SQs */
otx2_ctx_disable(&pf->mbox, NIX_AQ_CTYPE_SQ, false);
/* Free SQB pointers */
otx2_sq_free_sqbs(pf);
...
}
otx2_ctx_disable() returns void and only logs a mailbox failure. The NPA
pool and aura contexts are disabled later, in otx2_free_hw_resources():
/* Disable NPA Pool and Aura hw context */
otx2_ctx_disable(mbox, NPA_AQ_CTYPE_POOL, true);
otx2_ctx_disable(mbox, NPA_AQ_CTYPE_AURA, true);
otx2_aura_pool_free(pf);
So the SQB pages are freed before the NPA contexts are disabled. Only
pool->stack and pool->fc_addr are freed after that. If the AF mailbox is
still broken at ifdown, the memory kept by this patch gets freed anyway,
with no check of the result.
Could the commit message be reworded to match this?
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c b/drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c
> index 683efce519af0..e9ca884cfb4d5 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c
[ ... ]
> @@ -311,8 +311,16 @@ void otx2_qos_disable_sq(struct otx2_nic *pfvf, int qidx)
> otx2_cleanup_tx_cqes(pfvf, cq);
>
> mutex_lock(&pfvf->mbox.lock);
> - otx2_qos_ctx_disable(pfvf, sq_idx, pool_id);
> + err = otx2_qos_ctx_disable(pfvf, sq_idx, pool_id);
> mutex_unlock(&pfvf->mbox.lock);
> + if (err) {
> + /* The SQ, aura and pool may still be enabled, so don't free
> + * the memory they point to.
> + */
> + netdev_err(pfvf->netdev,
> + "Failed to disable QoS SQ %d (%d)\n", sq_idx, err);
> + return;
> + }
[Severity: Medium]
otx2_qos_disable_sq() still returns void, so callers can't tell that the
disable failed. When the same qid is set up again right afterwards, are
the kept SQB pages and queue buffers leaked?
otx2_qos_enadis_sq() re-enables the qid straight after the disable:
drivers/net/ethernet/marvell/octeontx2/nic/qos.c:otx2_qos_enadis_sq() {
if (pfvf->qos.qid_to_sqmap[qid] != OTX2_QOS_INVALID_SQ)
otx2_qos_disable_sq(pfvf, qid);
pfvf->qos.qid_to_sqmap[qid] = node->schq;
otx2_qos_txschq_config(pfvf, node);
otx2_qos_enable_sq(pfvf, qid);
}
otx2_qos_leaf_del() works the same way. It disables node->qid and later
calls otx2_qos_enable_sq(pfvf, qid) for the moved leaf.
otx2_qos_leaf_to_inner() and otx2_qos_leaf_del_last() pass the qid to a
child or parent. That node is then enabled through
push_txschq_cfg()->otx2_qos_enadis_sq().
The setup path overwrites the kept pointers without checking them:
drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c:otx2_qos_sq_aura_pool_init() {
...
sq->sqb_count = 0;
sq->sqb_ptrs = kzalloc_objs(*sq->sqb_ptrs, num_sqbs);
...
}
In the same way, otx2_pool_aq_init() always calls qmem_alloc() for
pool->stack. otx2_sq_init() also reallocates sq->sqe, sq->sqe_ring,
sq->cpt_resp and sq->sg.
After that, the old SQB pages stay DMA mapped and keep their page
references. The old qmem buffers are never freed, because
otx2_free_hw_resources() only sees the new pointers. pool->fc_addr is
fine, since otx2_aura_aq_init() reuses it when it is non-NULL.
With default ring sizes this comes to roughly 2 MiB each time. The
commit message only covers the case where the queue is not set up again.
In the common callers the queue is set up again in the same call.
Could otx2_qos_disable_sq() return the error so callers can avoid
reusing the qid? Alternatively, otx2_qos_enable_sq() could refuse, or
retry the disable and free first, while sq->sqb_ptrs is still set.
>
> otx2_qos_sq_free_sqbs(pfvf, sq_idx);
[Severity: High]
This is a pre-existing issue and was not introduced by this patch. Does
otx2_qos_sq_free_sqbs() leak sq->sqe_ring and sq->cpt_resp on every
successful disable?
otx2_sq_init() allocates both buffers for every SQ, QoS SQs included,
with no qidx condition. Those allocations came in with commit
6a77a158848a ("cn10k-ipsec: Process outbound ipsec crypto offload").
otx2_qos_sq_free_sqbs() frees the other buffers and then clears the
struct:
drivers/net/ethernet/marvell/octeontx2/nic/qos_sq.c:otx2_qos_sq_free_sqbs() {
...
qmem_free(pfvf->dev, sq->sqe);
qmem_free(pfvf->dev, sq->tso_hdrs);
kfree(sq->sg);
kfree(sq->sqb_ptrs);
qmem_free(pfvf->dev, sq->timestamps);
memset((void *)sq, 0, sizeof(*sq));
}
The only other place that frees them is otx2_free_sq_res(). It only does
so when sq->sqe is set, and the memset above has already cleared it:
if (sq->sqe) {
qmem_free(pf->dev, sq->sqe);
qmem_free(pf->dev, sq->sqe_ring);
qmem_free(pf->dev, sq->cpt_resp);
The qmem buffers come from otx2_dma_alloc_coherent(), which uses
kzalloc() and dma_map_single(), so they are not devm managed.
With the default sqe_cnt of 4096, each HTB leaf delete, leaf-to-inner,
leaf delete-last, or re-config through otx2_qos_enadis_sq() would leak
about 1 MiB for sqe_ring and 256 KiB for cpt_resp, plus their DMA
mappings. This happens on the normal success path and can be repeated.
> otx2_qos_aura_pool_free(pfvf, pool_id);
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124190046.415260-2-oss.patchbox%40gmail.com
Technical Details
Message-ID:
<179567645260.3135.1714589619526936893@kernel.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!news-ams.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371917-linux-kernel-netdev=dewy.ruReferences:
<20261124190046.415260-2-oss.patchbox@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!news-ams.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371917-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] octeontx2-pf: QOS: Don't free SQ memory if disabling the SQ fails Date: Thu, 26 Nov 2026 07:00:52 +0000 Organization: Usenet Network Message-ID: <179567645260.3135.1714589619526936893@kernel.org> References: <20261124190046.415260-2-oss.patchbox@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="403496"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:KBZeWvLswL2rL0jkFB5NAeRQ5b8= sha256:lSNM7QAc7RbLzCBAxJbW+WFd7CfZC9Xo1kAi3rXFsd4= sha1:soogIWzWxVzsIIHTEAchJY+JRes= sha256:GyySA4h64Ttx3/vC+89S2dDWxrCli75HbeB9PDCL1CI= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id E8234125EB5; Thu, 26 Nov 2026 10:01:24 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yvyiWiTAng7L; Thu, 26 Nov 2026 10:01:17 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-371917-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 86B89125EB4; Thu, 26 Nov 2026 10:00:58 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id E4D6A2D48E; Thu, 26 Nov 2026 07:00:55 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795676455; b=rTSr6eVUaDJH1/KQzdgUw71NTGFhiLdoCG5X6hI6nBcAEIM+RApMi2Y81icopXTxcu8s xbq187dsTfeJ7rQwrlidP+3UmpGQXUrZOvJEB+w8JEQEM/rvupQwPnSlwgVZHX4JugOQg qiJNXBQBhkyCANlHYMTDOgIUTAzDy//jRToAmeYvKTiGL0Hz/wwaM0bti+OmcyBwGJtar Ft3CEDpYD7NwRgdNJ/Slb5NfZ/ewzezqACXjRYk48RsAt0F2HXLetg6Y2MfSp2qFVyId0 n2rF5AeFA0uMedXqVUQntZ74yCB4ElM6piwsR8mmqvBmISggeRpAuVd7mcYppq9Glvg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795676455; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=5egdyMUL//oHT60ACbwW69GJ0v66WMLNl92315/6tfM=; b=cBpu/8rmGWQVPfj1aVbMq4jvmTWOTrtdN1s5jM7HOpoxcaQ/JEoRNrg0csCnmDUv/4yX 1dcuPvMags975MIufQhP8iTqGlQXQPl5KXOgOpJRbvo6n1RusBwjs7oHZe4Qb+pYuYwbZ r28tGSEhNGWBfQbdvnYBjReqoxBkIBKMKF4TRG0JdgjTZAW/W4gmjV+5bVCo/bEC6obt1 E13xE5RIL5dL/ssUvjaMlHeUvq3Di+P+R/3lnTCqDI7b35+pW6jmKH89UZXx1vcKBI/WO ISqNPPObflZuSTRGNCSj38KJJZ5b39+NPURorhBWkyVEaVGBKDhG+h0Y/uDl5sZfyWA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EefzDLSe; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BCD79606A32A; Thu, 26 Nov 2026 07:00:55 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EefzDLSe X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795676454; b=nUgiapA3UU/ja6KncNgyR0uRj0FM07OzZy46F6UMLben+2Nw3rCYdaNuMXrcVrOYmLPQ o2k80Oybe2M6QDTtq8KOvyLEmImFv+GgWUElav1DozBlZhdwFMwyOacSZzSWUuTgZiDDP FZ9251StqDyHeiOVvtgIFX+rTBobC/k6k2OsEevXqElJoTV4XRcTN6eETANWRrb2uv15g CBvSHtbXnYNB04byF5CST9YJeCvGyeJAPHYY5pC4AhvWL8ggW+oe0/rkruPAHsROoHsH8 vuToAVV9ilME0p113zrPQD90OOmAiVEjzH9Pr/Dp5O5p6LqQoixpCh6gCwvoLuymW8g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795676454; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=5egdyMUL//oHT60ACbwW69GJ0v66WMLNl92315/6tfM=; b=hiqehImubuv/KJjQiHiXDdn6HbgsZ8tviIb4KuBJ/HiP4UnwfjEUUtA0kxyeTu2Nt1CV zQ0gcrHO3KRdRh3y25eMEkiAzm43CWLzYK6d73JBxhgWrWWAy5+YjCxyGC4yAhG7xhUVe eRfNo2L+kNXyR4lMyX4JWbWWVAP2isyO+FOf1iQRcBUePNzaVNv4KKa8GB7FNLE9eB6HS UazMCCFuHDxlB6/modWlRQAB+bniyi+NmXcNoNmOGAJ7JtaM0d2zV3aLOvku0qdc5u1a3 wabj4oUcRmO6PP/sffSBgFOMkhbXcA4oG/vf4HxIYPpF9KFkXmWRe3YO1X+4cnGdf6g== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EefzDLSe; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9347606A31C for <netdev@vger.kernel.org>; Thu, 26 Nov 2026 07:00:54 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16A731F000D3; Thu, 26 Nov 2026 07:00:53 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795676453; bh=5egdyMUL//oHT60ACbwW69GJ0v66WMLNl92315/6tfM=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=EefzDLSeGQmRXjNH7bKZMx/eLlYDedDH9dSaFpEM38KInYGJfMElSeNEC0X769AHQ Urw6WkzfZEwg/lpZbUdPOJStvdglzfOx0L3YZ0gobMN3+jTsN3vrp2aN42zOP7UDUM b1/WNNGfLA+6vEk78XxhqBCqQ+BArIrTUXMDpvcZq572ze4CX8RwIsQCYn8kH4iiXz 5FNBqxKNkS6IR19HTgHYa7NOpWBfHO8jjhpqYHaXUalyBNdHCl8JOaKO1D1knCLAkv TegyAiYPpZGLaDi+Me8tf6wL1+CQW21deRk6JcDimiNeSya7f3pWjja+LPABvLWCrj UTuyFCcX4wayg== X-Cc: sgoutham@marvell.com, gakula@marvell.com, rkannoth@marvell.com, sbhatta@marvell.com, bbhushan2@marvell.com, hkelam@marvell.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, jacob.e.keller@intel.com, netdev@vger.kernel.org X-In-Reply-To: <20261124190046.415260-2-oss.patchbox@gmail.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list