Skip to content

Commit 6884cb2

Browse files
Yuuoniygregkh
authored andcommitted
scsi: iscsi: Fix missing scsi_host_put() in error path
[ Upstream commit 72eea84 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 52f2240 commit 6884cb2

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
@@ -3209,11 +3209,14 @@ iscsi_set_host_param(struct iscsi_transport *transport,
32093209
}
32103210

32113211
/* see similar check in iscsi_if_set_param() */
3212-
if (strlen(data) > ev->u.set_host_param.len)
3213-
return -EINVAL;
3212+
if (strlen(data) > ev->u.set_host_param.len) {
3213+
err = -EINVAL;
3214+
goto out;
3215+
}
32143216

32153217
err = transport->set_host_param(shost, ev->u.set_host_param.param,
32163218
data, ev->u.set_host_param.len);
3219+
out:
32173220
scsi_host_put(shost);
32183221
return err;
32193222
}

0 commit comments

Comments
 (0)