From patchwork Wed Jun 2 16:09:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sridhar Samudrala X-Patchwork-Id: 103837 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o52GA1hf032248 for ; Wed, 2 Jun 2010 16:10:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932679Ab0FBQJn (ORCPT ); Wed, 2 Jun 2010 12:09:43 -0400 Received: from e1.ny.us.ibm.com ([32.97.182.141]:37908 "EHLO e1.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758030Ab0FBQJm (ORCPT ); Wed, 2 Jun 2010 12:09:42 -0400 Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by e1.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o52G3qiM010759 for ; Wed, 2 Jun 2010 12:03:52 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o52G9eJ91224782 for ; Wed, 2 Jun 2010 12:09:40 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o52G9doW030517 for ; Wed, 2 Jun 2010 13:09:40 -0300 Received: from [9.47.18.19] (w-sridhar.beaverton.ibm.com [9.47.18.19]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o52G9cc6030489; Wed, 2 Jun 2010 13:09:39 -0300 Subject: [PATCH] Fix bugs in msix_set/unset_mask_notifier() routines From: Sridhar Samudrala To: "Michael S. Tsirkin" , Avi Kivity Cc: "kvm@vger.kernel.org" Date: Wed, 02 Jun 2010 09:09:37 -0700 Message-Id: <1275494978.989.62.camel@w-sridhar.beaverton.ibm.com> Mime-Version: 1.0 X-Mailer: Evolution 2.26.3 (2.26.3-1.fc11) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 02 Jun 2010 16:10:04 +0000 (UTC) diff --git a/hw/msix.c b/hw/msix.c index 1398680..a191df1 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -609,7 +609,7 @@ void msix_unuse_all_vectors(PCIDevice *dev) int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque) { - int r; + int r = 0; if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector]) return 0; @@ -619,13 +619,15 @@ int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque) /* Unmask the new notifier unless vector is masked. */ if (msix_is_masked(dev, vector)) { - return 0; + goto out; } r = dev->msix_mask_notifier(dev, vector, opaque, msix_is_masked(dev, vector)); if (r < 0) { return r; } + +out: dev->msix_mask_notifier_opaque[vector] = opaque; return r; } @@ -640,8 +642,8 @@ int msix_unset_mask_notifier(PCIDevice *dev, unsigned vector) assert(dev->msix_mask_notifier_opaque[vector]); /* Mask the old notifier unless it is already masked. */ - if (msix_is_masked(dev, vector)) { - return 0; + if (!msix_is_masked(dev, vector)) { + goto out; } r = dev->msix_mask_notifier(dev, vector, dev->msix_mask_notifier_opaque[vector], @@ -649,6 +651,8 @@ int msix_unset_mask_notifier(PCIDevice *dev, unsigned vector) if (r < 0) { return r; } + +out: dev->msix_mask_notifier_opaque[vector] = NULL; return r; }