From patchwork Thu Jul 23 13:34:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 36967 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6NDZIWo022340 for ; Thu, 23 Jul 2009 13:35:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754017AbZGWNfL (ORCPT ); Thu, 23 Jul 2009 09:35:11 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754195AbZGWNfL (ORCPT ); Thu, 23 Jul 2009 09:35:11 -0400 Received: from mx2.redhat.com ([66.187.237.31]:37899 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751060AbZGWNfK (ORCPT ); Thu, 23 Jul 2009 09:35:10 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6NDZBeo027950 for ; Thu, 23 Jul 2009 09:35:11 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n6NDZ9uU010562; Thu, 23 Jul 2009 09:35:10 -0400 Received: from redhat.com (dhcp-0-94.tlv.redhat.com [10.35.0.94]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n6NDZ7Ni026295; Thu, 23 Jul 2009 09:35:08 -0400 Date: Thu, 23 Jul 2009 16:34:13 +0300 From: "Michael S. Tsirkin" To: avi@redhat.com, kvm@vger.kernel.org, amit.shah@redhat.com Subject: [PATCH] qemu-kvm: fix error handling in msix vector add Message-ID: <20090723133413.GA12944@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When adding a vector fails, the used counter should not be incremented, otherwise on vector change we will try to update the routing entry. Signed-off-by: Michael S. Tsirkin --- hw/msix.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/msix.c b/hw/msix.c index 5f77dc9..47cbdc7 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -502,13 +502,19 @@ void msix_reset(PCIDevice *dev) /* Mark vector as used. */ int msix_vector_use(PCIDevice *dev, unsigned vector) { + int ret; if (vector >= dev->msix_entries_nr) return -EINVAL; - if (dev->msix_entry_used[vector]++) + if (dev->msix_entry_used[vector]) { return 0; + } if (kvm_enabled() && qemu_kvm_irqchip_in_kernel()) { - return kvm_msix_add(dev, vector); + ret = kvm_msix_add(dev, vector); + if (ret) { + return ret; + } } + ++dev->msix_entry_used[vector]; return 0; }