Commit ae187fec authored by Will Deacon's avatar Will Deacon Committed by Marc Zyngier
Browse files

KVM: arm64: Return error from kvm_arch_init_vm() on allocation failure



If we fail to allocate the 'supported_cpus' cpumask in kvm_arch_init_vm()
then be sure to return -ENOMEM instead of success (0) on the failure
path.

Reviewed-by: default avatarAlexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: default avatarWill Deacon <will@kernel.org>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20220609121223.2551-2-will@kernel.org
parent efedd01d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -150,8 +150,10 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
	if (ret)
		goto out_free_stage2_pgd;

	if (!zalloc_cpumask_var(&kvm->arch.supported_cpus, GFP_KERNEL))
	if (!zalloc_cpumask_var(&kvm->arch.supported_cpus, GFP_KERNEL)) {
		ret = -ENOMEM;
		goto out_free_stage2_pgd;
	}
	cpumask_copy(kvm->arch.supported_cpus, cpu_possible_mask);

	kvm_vgic_early_init(kvm);