KVM: x86: drop unneeded null test
authorJulia Lawall <Julia.Lawall@lip6.fr>
Mon, 27 Apr 2015 20:35:34 +0000 (22:35 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 7 May 2015 09:29:47 +0000 (11:29 +0200)
If the null test is needed, the call to cancel_delayed_work_sync would have
already crashed.  Normally, the destroy function should only be called
if the init function has succeeded, in which case ioapic is not null.

Problem found using Coccinelle.

Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/ioapic.c

index 274663496f7a283bee8acc601b2cd895cf43d798..856f79105bb59fcb14650de8f2d35814115f646f 100644 (file)
@@ -638,11 +638,9 @@ void kvm_ioapic_destroy(struct kvm *kvm)
        struct kvm_ioapic *ioapic = kvm->arch.vioapic;
 
        cancel_delayed_work_sync(&ioapic->eoi_inject);
-       if (ioapic) {
-               kvm_io_bus_unregister_dev(kvm, KVM_MMIO_BUS, &ioapic->dev);
-               kvm->arch.vioapic = NULL;
-               kfree(ioapic);
-       }
+       kvm_io_bus_unregister_dev(kvm, KVM_MMIO_BUS, &ioapic->dev);
+       kvm->arch.vioapic = NULL;
+       kfree(ioapic);
 }
 
 int kvm_get_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state)