[PATCH] scsi: elx: efct: fix IO refcount leak in efct_hw_io_abort()

Wentao Liang posted 1 patch 1 week, 5 days ago
drivers/scsi/elx/efct/efct_hw.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] scsi: elx: efct: fix IO refcount leak in efct_hw_io_abort()
Posted by Wentao Liang 1 week, 5 days ago
efct_hw_io_abort() calls efct_hw_io_alloc() which initializes the IO
reference counter to 1. On the error path where the abort operation
fails after IO allocation, the function returns without calling
kref_put() to release the IO reference, leaking the refcount.

Add kref_put() on the error path to properly release the reference.

Fixes: 63de51327a64 ("scsi: elx: efct: Hardware I/O and SGL initialization")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 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..4ecd6f4165f4 100644
--- a/drivers/scsi/elx/efct/efct_hw.c
+++ b/drivers/scsi/elx/efct/efct_hw.c
@@ -1997,6 +1997,7 @@ efct_hw_io_abort(struct efct_hw *hw, struct efct_hw_io *io_to_abort,
 	wqcb = efct_hw_reqtag_alloc(hw, efct_hw_wq_process_abort, io_to_abort);
 	if (!wqcb) {
 		efc_log_err(hw->os, "can't allocate request tag\n");
+		kref_put(&io_to_abort->ref, io_to_abort->release);
 		return -ENOSPC;
 	}
 
-- 
2.34.1