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

Dawei Feng posted 1 patch 1 week, 3 days ago
drivers/scsi/elx/efct/efct_xport.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] scsi: elx: efct: fix resource leak in efct_xport_initialize()
Posted by Dawei Feng 1 week, 3 days ago
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
Re: [PATCH] scsi: elx: efct: fix resource leak in efct_xport_initialize()
Posted by Sebastian Andrzej Siewior 1 week, 3 days ago
On 2026-05-29 12:01:15 [+0800], Dawei Feng wrote:
> 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>

Based on inspection, it looks like the right thing to do.

Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Sebastian