Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: elx: efct: fix resource leak in efct_xport_initialize()
@ 2026-05-29  4:01 Dawei Feng
  2026-05-29  7:04 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 2+ messages in thread
From: Dawei Feng @ 2026-05-29  4:01 UTC (permalink / raw)
  To: ram.vegesna
  Cc: James.Bottomley, martin.petersen, bigeasy, kees, tglx, linux-scsi,
	target-devel, linux-kernel, jianhao.xu, Dawei Feng, stable,
	Zilin Guan

efct_device_attach() frees efct->xport when efct_xport_initialize()
fails, but efct_xport_initialize() returns directly when efct_hw_init()
fails. That skips efct_hw_teardown() and leaves the hardware resources
allocated by efct_xport_attach() behind before the transport object
itself is freed.

Route the efct_hw_init() error through the existing hw_init_out cleanup
path so the hardware teardown runs before returning.

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-rc5.

An x86_64 allyesconfig build showed no new warnings. As we do not have
access to an Emulex LPE31004/LPE36000 adapter to test with in this
environment, no runtime testing was able to beperformed.

Fixes: 4df84e846624 ("scsi: elx: efct: Driver initialization routines")
Cc: stable@vger.kernel.org
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Signed-off-by: Dawei Feng <dawei.feng@seu.edu.cn>
---
 drivers/scsi/elx/efct/efct_xport.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/elx/efct/efct_xport.c b/drivers/scsi/elx/efct/efct_xport.c
index 9dcaef6fc188..e7b7d2c3bbf3 100644
--- a/drivers/scsi/elx/efct/efct_xport.c
+++ b/drivers/scsi/elx/efct/efct_xport.c
@@ -229,7 +229,7 @@ efct_xport_initialize(struct efct_xport *xport)
 	rc = efct_hw_init(&efct->hw);
 	if (rc) {
 		efc_log_err(efct, "efct_hw_init failure\n");
-		goto out;
+		goto hw_init_out;
 	}
 
 	rc = efct_scsi_tgt_new_device(efct);
@@ -256,7 +256,6 @@ efct_xport_initialize(struct efct_xport *xport)
 
 hw_init_out:
 	efct_hw_teardown(&efct->hw);
-out:
 	return rc;
 }
 
-- 
2.34.1


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

end of thread, other threads:[~2026-05-29  7:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-29  4:01 [PATCH] scsi: elx: efct: fix resource leak in efct_xport_initialize() Dawei Feng
2026-05-29  7:04 ` Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox