KVM: make kvm_unregister_irq_ack_notifier() safe

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Friday, January 2, 2009 - 2:02 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=fdd897...
Commit:     fdd897e6b5253a45b633f7d334cf3e150bbaf386
Parent:     844c7a9ff404d8fc88bb77b06461644621d2c985
Author:     Mark McLoughlin <markmc@redhat.com>
AuthorDate: Mon Dec 1 13:57:46 2008 +0000
Committer:  Avi Kivity <avi@redhat.com>
CommitDate: Wed Dec 31 16:55:06 2008 +0200

    KVM: make kvm_unregister_irq_ack_notifier() safe
    
    We never pass a NULL notifier pointer here, but we may well
    pass a notifier struct which hasn't previously been
    registered.
    
    Guard against this by using hlist_del_init() which will
    not do anything if the node hasn't been added to the list
    and, when removing the node, will ensure that a subsequent
    call to hlist_del_init() will be fine too.
    
    Fixes an oops seen when an assigned device is freed before
    and IRQ is assigned to it.
    
    Signed-off-by: Mark McLoughlin <markmc@redhat.com>
    Signed-off-by: Avi Kivity <avi@redhat.com>
---
 virt/kvm/irq_comm.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index 973df99..db75045 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -63,9 +63,7 @@ void kvm_register_irq_ack_notifier(struct kvm *kvm,
 
 void kvm_unregister_irq_ack_notifier(struct kvm_irq_ack_notifier *kian)
 {
-	if (!kian)
-		return;
-	hlist_del(&kian->link);
+	hlist_del_init(&kian->link);
 }
 
 /* The caller must hold kvm->lock mutex */
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
KVM: make kvm_unregister_irq_ack_notifier() safe, Linux Kernel Mailing ..., (Fri Jan 2, 2:02 pm)