From 057fb1b4b227bc49aa00b08da5f177b50c020693 Mon Sep 17 00:00:00 2001 From: Michael S. Tsirkin Date: Thu, 23 Jul 2009 16:34:13 +0300 Subject: [PATCH] Fix error handling in msix vector add When adding a vector fails, the used counter should not be incremented, otherwise on vector change we will try to update the routing entry. (cherry picked from commit aca6915d92743b11ac5555d6e412cc4737f27f34) Signed-off-by: Michael S. Tsirkin Signed-off-by: Avi Kivity Signed-off-by: Mark McLoughlin Fedora-patch: qemu-fix-msix-error-handling-on-older-kernels.patch --- hw/msix.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/msix.c b/hw/msix.c index 974268d..b6c3f17 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -503,13 +503,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; } -- 1.6.2.5