diff mbox

KVM: PPC: check error return of kvmppc_core_vcpu_create first

Message ID 50A8F108-8055-4115-B4EB-706D97736E65@ubuntu.com
State New, archived
Headers show

Commit Message

Benjamin Collins Feb. 21, 2012, 4:30 a.m. UTC
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 <bcollins@ubuntu.com>


--
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

Comments

Alexander Graf March 5, 2012, 6:10 p.m. UTC | #1
On 02/21/2012 05:30 AM, Ben Collins wrote:
> 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.

Nice catch, but this has already been fixed by Matt:

commit c6f3830e7313eea47b526b597aadc5b18c69ad55
Author: Matt Evans <matt@ozlabs.org>
Date:   Tue Dec 6 21:19:42 2011 +0000

     KVM: PPC: Fix vcpu_create dereference before validity check.

     Fix usage of vcpu struct before check that it's actually valid.

     Signed-off-by: Matt Evans <matt@ozlabs.org>
     Signed-off-by: Alexander Graf <agraf@suse.de>


Thanks a lot for sending the patch nevertheless!

Alex

--
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 mbox

Patch

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;
 }