Commit 72eea84a authored by Miaoqian Lin's avatar Miaoqian Lin Committed by Martin K. Petersen
Browse files

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: ce51c817 ("scsi: iscsi: Add strlen() check in iscsi_if_set{_host}_param()")
Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
Link: https://lore.kernel.org/r/20250318094344.91776-1-linmq006@gmail.com


Reviewed-by: default avatarMike Christie <michael.christie@oracle.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 20b97acc
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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;
}