diff options
author | 2025-03-18 17:43:43 +0800 | |
---|---|---|
committer | 2025-04-03 09:46:03 -0400 | |
commit | 72eea84a1092b50a10eeecfeba4b28ac9f1312ab (patch) | |
tree | ab84c161fed648a293a19dd4d6cf764fc7cbb219 | |
parent | scsi: ufs: core: Fix a race condition related to device commands (diff) | |
download | wireguard-linux-72eea84a1092b50a10eeecfeba4b28ac9f1312ab.tar.xz wireguard-linux-72eea84a1092b50a10eeecfeba4b28ac9f1312ab.zip |
scsi: iscsi: Fix missing scsi_host_put() in error path
Add goto to ensure scsi_host_put() is called in all error paths of
iscsi_set_host_param() function. This fixes a potential memory leak when
strlen() check fails.
Fixes: ce51c8170084 ("scsi: iscsi: Add strlen() check in iscsi_if_set{_host}_param()")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Link: https://lore.kernel.org/r/20250318094344.91776-1-linmq006@gmail.com
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/scsi_transport_iscsi.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 9c347c64c315..0b8c91bf793f 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -3182,11 +3182,14 @@ iscsi_set_host_param(struct iscsi_transport *transport, } /* see similar check in iscsi_if_set_param() */ - if (strlen(data) > ev->u.set_host_param.len) - return -EINVAL; + if (strlen(data) > ev->u.set_host_param.len) { + err = -EINVAL; + goto out; + } err = transport->set_host_param(shost, ev->u.set_host_param.param, data, ev->u.set_host_param.len); +out: scsi_host_put(shost); return err; } |