[PATCH] scsi: elx: efct: fix resource leak in efct_xport_initialize()

From: Dawei Feng

Date: Fri May 29 2026 - 00:09:23 EST


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@xxxxxxxxxxxxxxx
Signed-off-by: Zilin Guan <zilin@xxxxxxxxxx>
Signed-off-by: Dawei Feng <dawei.feng@xxxxxxxxxx>
---
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