From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark McLoughlin Subject: [PATCH 2/5] KVM: make kvm_unregister_irq_ack_notifier() safe Date: Mon, 1 Dec 2008 13:57:46 +0000 Message-ID: <1228139869-5848-2-git-send-email-markmc@redhat.com> References: <1228139817.3870.30.camel@blaa> <1228139869-5848-1-git-send-email-markmc@redhat.com> Cc: kvm@vger.kernel.org, Mark McLoughlin To: Avi Kivity Return-path: Received: from mail13.svc.cra.dublin.eircom.net ([159.134.118.29]:46496 "HELO mail13.svc.cra.dublin.eircom.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751463AbYLAN7I (ORCPT ); Mon, 1 Dec 2008 08:59:08 -0500 In-Reply-To: <1228139869-5848-1-git-send-email-markmc@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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 */ -- 1.5.4.3