aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2009-07-23 16:34:13 +0300
committerAvi Kivity <avi@redhat.com>2009-09-09 15:07:25 +0300
commitc5863ce628d07d3adcc8df52ecba6e915f7eb4d9 (patch)
tree10df19b73527be585de9caa8111c9d5faae9efa2
parentc06b44bfc9814930b6a94db7bbeb3be1cd39c0d2 (diff)
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. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--hw/msix.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/hw/msix.c b/hw/msix.c
index 974268d33..b6c3f1746 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;
}