[PATCH] scsi: elx: efct: Fix potential memory leak in efct_hw_parse_filter()

Abdun Nihaal <[email protected]> Wed, 1 Jul 2026 11:53:08 +0530
Newsgroups org.kernel.vger.target-devel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-scsi
Message-ID <[email protected]>
When an empty string is provided as the value, the error check after
kstrdup() call, can fail even when a small buffer is allocated for the
null terminated empty string. Fix that by freeing it before returning.

Fixes: 4df84e846624 ("scsi: elx: efct: Driver initialization routines")
Signed-off-by: Abdun Nihaal <[email protected]>
---
Compile tested only. Issue found using static analysis.

 drivers/scsi/elx/efct/efct_hw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/elx/efct/efct_hw.c b/drivers/scsi/elx/efct/efct_hw.c
index 1838032f6486..b0fdeabb9d05 100644
--- a/drivers/scsi/elx/efct/efct_hw.c
+++ b/drivers/scsi/elx/efct/efct_hw.c
@@ -1129,6 +1129,7 @@ efct_hw_parse_filter(struct efct_hw *hw, void *value)
 
 	p = kstrdup(value, GFP_KERNEL);
 	if (!p || !*p) {
+		kfree(p);
 		efc_log_err(hw->os, "p is NULL\n");
 		return -ENOMEM;
 	}
-- 
2.43.0