Skip to content

Commit 5b4fb1d

Browse files
committed
scsi: iscsi: Fix missing scsi_host_put() in error path
JIRA: https://issues.redhat.com/browse/RHEL-90552 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: ce51c81 ("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> (cherry picked from commit 72eea84) Signed-off-by: Chris Leech <cleech@redhat.com>
1 parent b2b1d52 commit 5b4fb1d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/scsi/scsi_transport_iscsi.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,11 +3182,14 @@ iscsi_set_host_param(struct iscsi_transport *transport,
31823182
}
31833183

31843184
/* see similar check in iscsi_if_set_param() */
3185-
if (strlen(data) > ev->u.set_host_param.len)
3186-
return -EINVAL;
3185+
if (strlen(data) > ev->u.set_host_param.len) {
3186+
err = -EINVAL;
3187+
goto out;
3188+
}
31873189

31883190
err = transport->set_host_param(shost, ev->u.set_host_param.param,
31893191
data, ev->u.set_host_param.len);
3192+
out:
31903193
scsi_host_put(shost);
31913194
return err;
31923195
}

0 commit comments

Comments
 (0)