From patchwork Tue Feb 21 04:30:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: KVM: PPC: check error return of kvmppc_core_vcpu_create first Date: Mon, 20 Feb 2012 18:30:11 -0000 From: Benjamin Collins X-Patchwork-Id: 142239 Message-Id: <50A8F108-8055-4115-B4EB-706D97736E65@ubuntu.com> To: Alexander Graf Cc: kvm-ppc@vger.kernel.org, linux-kernel@vger.kernel.org The result of kvmppc_core_vcpu_create() was being manipulated before it was checked for IS_ERR(). Did not see the bug occur, but caught it when looking through the code. Signed-off-by: Ben Collins --- Bluecherry: http://www.bluecherrydvr.com/ SwissDisk : http://www.swissdisk.com/ Ubuntu : http://www.ubuntu.com/ My Blog : http://ben-collins.blogspot.com/ -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 607fbdf..8877614 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -278,10 +278,14 @@ void kvm_arch_flush_shadow(struct kvm *kvm) struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id) { struct kvm_vcpu *vcpu; + vcpu = kvmppc_core_vcpu_create(kvm, id); + if (IS_ERR(vcpu)) + return vcpu; + vcpu->arch.wqp = &vcpu->wq; - if (!IS_ERR(vcpu)) - kvmppc_create_vcpu_debugfs(vcpu, id); + kvmppc_create_vcpu_debugfs(vcpu, id); + return vcpu; }