Re: [PATCH v2 01/45] KVM: PPC: Book3S HV: Uninit vCPU if vcore creation fails

2020-01-19 Thread Paul Mackerras
On Wed, Dec 18, 2019 at 01:54:46PM -0800, Sean Christopherson wrote:
> Call kvm_vcpu_uninit() if vcore creation fails to avoid leaking any
> resources allocated by kvm_vcpu_init(), i.e. the vcpu->run page.
> 
> Fixes: 371fefd6f2dc4 ("KVM: PPC: Allow book3s_hv guests to use SMT processor 
> modes")
> Cc: sta...@vger.kernel.org
> Reviewed-by: Greg Kurz 
> Signed-off-by: Sean Christopherson 
> ---
>  arch/powerpc/kvm/book3s_hv.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index dc53578193ee..d07d2f5273e5 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -2368,7 +2368,7 @@ static struct kvm_vcpu 
> *kvmppc_core_vcpu_create_hv(struct kvm *kvm,
>   mutex_unlock(>lock);
>  
>   if (!vcore)
> - goto free_vcpu;
> + goto uninit_vcpu;
>  
>   spin_lock(>lock);
>   ++vcore->num_threads;
> @@ -2385,6 +2385,8 @@ static struct kvm_vcpu 
> *kvmppc_core_vcpu_create_hv(struct kvm *kvm,
>  
>   return vcpu;
>  
> +uninit_vcpu:
> + kvm_vcpu_uninit(vcpu);
>  free_vcpu:
>   kmem_cache_free(kvm_vcpu_cache, vcpu);
>  out:
> -- 
> 2.24.1

Looks correct.

Acked-by: Paul Mackerras 
___
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm


[PATCH v2 01/45] KVM: PPC: Book3S HV: Uninit vCPU if vcore creation fails

2019-12-18 Thread Sean Christopherson
Call kvm_vcpu_uninit() if vcore creation fails to avoid leaking any
resources allocated by kvm_vcpu_init(), i.e. the vcpu->run page.

Fixes: 371fefd6f2dc4 ("KVM: PPC: Allow book3s_hv guests to use SMT processor 
modes")
Cc: sta...@vger.kernel.org
Reviewed-by: Greg Kurz 
Signed-off-by: Sean Christopherson 
---
 arch/powerpc/kvm/book3s_hv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index dc53578193ee..d07d2f5273e5 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -2368,7 +2368,7 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_hv(struct 
kvm *kvm,
mutex_unlock(>lock);
 
if (!vcore)
-   goto free_vcpu;
+   goto uninit_vcpu;
 
spin_lock(>lock);
++vcore->num_threads;
@@ -2385,6 +2385,8 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_hv(struct 
kvm *kvm,
 
return vcpu;
 
+uninit_vcpu:
+   kvm_vcpu_uninit(vcpu);
 free_vcpu:
kmem_cache_free(kvm_vcpu_cache, vcpu);
 out:
-- 
2.24.1

___
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm