Skip to content

Commit

Permalink
KVM: make kvm_unregister_irq_ack_notifier() safe
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mark McLoughlin authored and Avi Kivity committed Dec 31, 2008
1 parent 844c7a9 commit fdd897e
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions virt/kvm/irq_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit fdd897e

Please sign in to comment.