diff mbox

KVM: x86: drop unneeded null test

Message ID 1430166934-30834-1-git-send-email-Julia.Lawall@lip6.fr (mailing list archive)
State New, archived
Headers show

Commit Message

Julia Lawall April 27, 2015, 8:35 p.m. UTC
From: Julia Lawall <Julia.Lawall@lip6.fr>

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 functoin has succeeded, in which case ioapic is not null.

Problem found using Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 arch/x86/kvm/ioapic.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Michael S. Tsirkin April 27, 2015, 8:50 p.m. UTC | #1
On Mon, Apr 27, 2015 at 10:35:34PM +0200, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> 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 functoin has succeeded, in which case ioapic is not null.
> 
> Problem found using Coccinelle.
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> 
> ---
>  arch/x86/kvm/ioapic.c |    8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/kvm/ioapic.c b2/arch/x86/kvm/ioapic.c
> index 28146f0..09828e2 100644
> --- a/arch/x86/kvm/ioapic.c
> +++ b2/arch/x86/kvm/ioapic.c
> @@ -637,11 +637,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)
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paolo Bonzini April 28, 2015, 9:57 a.m. UTC | #2
On 27/04/2015 22:35, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> 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 functoin has succeeded, in which case ioapic is not null.
> 
> Problem found using Coccinelle.
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Applied, thanks.

Paolo

> ---
>  arch/x86/kvm/ioapic.c |    8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/kvm/ioapic.c b2/arch/x86/kvm/ioapic.c
> index 28146f0..09828e2 100644
> --- a/arch/x86/kvm/ioapic.c
> +++ b2/arch/x86/kvm/ioapic.c
> @@ -637,11 +637,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)
> 
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
SF Markus Elfring April 28, 2015, 5:21 p.m. UTC | #3
> 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 functoin has succeeded, in which case ioapic is not null.

Does your commit message need a small fix?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kvm" 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/x86/kvm/ioapic.c b2/arch/x86/kvm/ioapic.c
index 28146f0..09828e2 100644
--- a/arch/x86/kvm/ioapic.c
+++ b2/arch/x86/kvm/ioapic.c
@@ -637,11 +637,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)