From: Thomas Fourier <fourier.thomas@gmail.com>
Cc: Thomas Fourier <fourier.thomas@gmail.com>,
Potnuri Bharat Teja <bharat@chelsio.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Hariprasad Shenai <hariprasad@chelsio.com>,
netdev@vger.kernel.org (open list:CXGB4 ETHERNET DRIVER (CXGB4)),
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH net] cxgb4: clear the sge maps and bitmaps freed on adap_init0() failure
Date: Wed, 4 Nov 2026 11:33:08 +0100 [thread overview]
Message-ID: <20261104103309.24360-2-fourier.thomas@gmail.com> (raw)
The bye: label of adap_init0() frees sge.egr_map, sge.ingr_map,
sge.starving_fl, sge.txq_maperr and sge.blocked_fl but leaves the
pointers set. If the call of adapt_init0() from eeh_reset_done() fails,
then a subsequent call to remove_one() may call free_some_resources(), and
free the resource again.
Clear the pointers after freeing them.
This bug is theoretical and was found statically.
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Fixes: 4b8e27a86d20 ("cxgb4: Allocate dynamic mem. for egress and ingress queue maps")
---
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index d449cca00608..9176653c7d70 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -5402,11 +5402,16 @@ static int adap_init0(struct adapter *adap, int vpd_skip)
bye:
adap_free_hma_mem(adap);
kfree(adap->sge.egr_map);
+ adap->sge.egr_map = NULL;
kfree(adap->sge.ingr_map);
+ adap->sge.ingr_map = NULL;
bitmap_free(adap->sge.starving_fl);
+ adap->sge.starving_fl = NULL;
bitmap_free(adap->sge.txq_maperr);
+ adap->sge.txq_maperr = NULL;
#ifdef CONFIG_DEBUG_FS
bitmap_free(adap->sge.blocked_fl);
+ adap->sge.blocked_fl = NULL;
#endif
if (ret != -ETIMEDOUT && ret != -EIO)
t4_fw_bye(adap, adap->mbox);
--
2.53.0
next reply other threads:[~2026-11-04 10:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 10:33 Thomas Fourier [this message]
2026-11-04 10:39 ` netdev-bot+sinfo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261104103309.24360-2-fourier.thomas@gmail.com \
--to=fourier.thomas@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=bharat@chelsio.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hariprasad@chelsio.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®