Skip to content

Commit 72eea84

Browse files
Yuuoniymartinkpetersen
authored andcommitted
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: ce51c81 ("scsi: iscsi: Add strlen() check in iscsi_if_set{_host}_param()") Signed-off-by: Miaoqian Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Mike Christie <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 20b97ac commit 72eea84

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)