When nestedv2 is enabled, kvmppc_core_vcpu_create_hv() allocates guest state buffers and messages through kvmhv_nestedv2_vcpu_create(). If the subsequent vcore lookup or allocation fails, it returns without releasing those resources. The caller's error path only calls kvmppc_subarch_vcpu_uninit(), which does not free the nestedv2 state. Call kvmhv_nestedv2_vcpu_free() before returning from the vcore error path when nestedv2 is enabled. Fixes: 19d31c5f1157 ("KVM: PPC: Add support for nestedv2 guests") Signed-off-by: Haoxiang Li --- arch/powerpc/kvm/book3s_hv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 22283d46e8fe..1a1a4e3ba412 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -3097,8 +3097,11 @@ static int kvmppc_core_vcpu_create_hv(struct kvm_vcpu *vcpu) } } - if (!vcore) + if (!vcore) { + if (kvmhv_is_nestedv2()) + kvmhv_nestedv2_vcpu_free(vcpu, &vcpu->arch.nestedv2_io); return err; + } spin_lock(&vcore->lock); ++vcore->num_threads; -- 2.25.1