mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] cxgb4: clear the sge maps and bitmaps freed on adap_init0()  failure
@ 2026-11-04 10:33 Thomas Fourier
  2026-11-04 10:39 ` netdev-bot+sinfo
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Fourier @ 2026-11-04 10:33 UTC (permalink / raw)
  Cc: Thomas Fourier, Potnuri Bharat Teja, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Hariprasad Shenai, open list:CXGB4 ETHERNET DRIVER (CXGB4),
	open list

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


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

end of thread, other threads:[~2026-11-04 10:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 10:33 [PATCH net] cxgb4: clear the sge maps and bitmaps freed on adap_init0() failure Thomas Fourier
2026-11-04 10:39 ` netdev-bot+sinfo

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®