diff options
-rw-r--r-- | virt/kvm/irq_comm.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index db75045f22f6..aa5d1e5c497e 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c | |||
@@ -72,11 +72,15 @@ int kvm_request_irq_source_id(struct kvm *kvm) | |||
72 | unsigned long *bitmap = &kvm->arch.irq_sources_bitmap; | 72 | unsigned long *bitmap = &kvm->arch.irq_sources_bitmap; |
73 | int irq_source_id = find_first_zero_bit(bitmap, | 73 | int irq_source_id = find_first_zero_bit(bitmap, |
74 | sizeof(kvm->arch.irq_sources_bitmap)); | 74 | sizeof(kvm->arch.irq_sources_bitmap)); |
75 | |||
75 | if (irq_source_id >= sizeof(kvm->arch.irq_sources_bitmap)) { | 76 | if (irq_source_id >= sizeof(kvm->arch.irq_sources_bitmap)) { |
76 | printk(KERN_WARNING "kvm: exhaust allocatable IRQ sources!\n"); | 77 | printk(KERN_WARNING "kvm: exhaust allocatable IRQ sources!\n"); |
77 | irq_source_id = -EFAULT; | 78 | return -EFAULT; |
78 | } else | 79 | } |
79 | set_bit(irq_source_id, bitmap); | 80 | |
81 | ASSERT(irq_source_id != KVM_USERSPACE_IRQ_SOURCE_ID); | ||
82 | set_bit(irq_source_id, bitmap); | ||
83 | |||
80 | return irq_source_id; | 84 | return irq_source_id; |
81 | } | 85 | } |
82 | 86 | ||
@@ -84,7 +88,9 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id) | |||
84 | { | 88 | { |
85 | int i; | 89 | int i; |
86 | 90 | ||
87 | if (irq_source_id <= 0 || | 91 | ASSERT(irq_source_id != KVM_USERSPACE_IRQ_SOURCE_ID); |
92 | |||
93 | if (irq_source_id < 0 || | ||
88 | irq_source_id >= sizeof(kvm->arch.irq_sources_bitmap)) { | 94 | irq_source_id >= sizeof(kvm->arch.irq_sources_bitmap)) { |
89 | printk(KERN_ERR "kvm: IRQ source ID out of range!\n"); | 95 | printk(KERN_ERR "kvm: IRQ source ID out of range!\n"); |
90 | return; | 96 | return; |