Commit 6baaeda8 authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini
Browse files

KVM: arm64: Free hypervisor allocations if vector slot init fails



Teardown hypervisor mode if vector slot setup fails in order to avoid
leaking any allocations done by init_hyp_mode().

Fixes: b881cdce ("KVM: arm64: Allocate hyp vectors statically")
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Message-Id: <20221130230934.1014142-18-seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 466d27e4
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -2249,18 +2249,18 @@ int kvm_arch_init(void *opaque)
	err = kvm_init_vector_slots();
	if (err) {
		kvm_err("Cannot initialise vector slots\n");
		goto out_err;
		goto out_hyp;
	}

	err = init_subsystems();
	if (err)
		goto out_hyp;
		goto out_subs;

	if (!in_hyp_mode) {
		err = finalize_hyp_mode();
		if (err) {
			kvm_err("Failed to finalize Hyp protection\n");
			goto out_hyp;
			goto out_subs;
		}
	}

@@ -2274,8 +2274,9 @@ int kvm_arch_init(void *opaque)

	return 0;

out_hyp:
out_subs:
	hyp_cpu_pm_exit();
out_hyp:
	if (!in_hyp_mode)
		teardown_hyp_mode();
out_err: