summaryrefslogtreecommitdiffstats
path: root/virt/kvm/irqchip.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2019-04-11 05:16:47 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2019-04-16 09:38:07 -0400
commit1d487e9bf8ba66a7174c56a0029c54b1eca8f99c (patch)
tree4916036d4dc25e9a52ba59105621ee42682ce844 /virt/kvm/irqchip.c
parentbe43c440eb5d0ccfdb0d67d5a4c9d579ff988b75 (diff)
KVM: fix spectrev1 gadgets
These were found with smatch, and then generalized when applicable. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt/kvm/irqchip.c')
-rw-r--r--virt/kvm/irqchip.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/virt/kvm/irqchip.c b/virt/kvm/irqchip.c
index 3547b0d8c91e..79e59e4fa3dc 100644
--- a/virt/kvm/irqchip.c
+++ b/virt/kvm/irqchip.c
@@ -144,18 +144,19 @@ static int setup_routing_entry(struct kvm *kvm,
144{ 144{
145 struct kvm_kernel_irq_routing_entry *ei; 145 struct kvm_kernel_irq_routing_entry *ei;
146 int r; 146 int r;
147 u32 gsi = array_index_nospec(ue->gsi, KVM_MAX_IRQ_ROUTES);
147 148
148 /* 149 /*
149 * Do not allow GSI to be mapped to the same irqchip more than once. 150 * Do not allow GSI to be mapped to the same irqchip more than once.
150 * Allow only one to one mapping between GSI and non-irqchip routing. 151 * Allow only one to one mapping between GSI and non-irqchip routing.
151 */ 152 */
152 hlist_for_each_entry(ei, &rt->map[ue->gsi], link) 153 hlist_for_each_entry(ei, &rt->map[gsi], link)
153 if (ei->type != KVM_IRQ_ROUTING_IRQCHIP || 154 if (ei->type != KVM_IRQ_ROUTING_IRQCHIP ||
154 ue->type != KVM_IRQ_ROUTING_IRQCHIP || 155 ue->type != KVM_IRQ_ROUTING_IRQCHIP ||
155 ue->u.irqchip.irqchip == ei->irqchip.irqchip) 156 ue->u.irqchip.irqchip == ei->irqchip.irqchip)
156 return -EINVAL; 157 return -EINVAL;
157 158
158 e->gsi = ue->gsi; 159 e->gsi = gsi;
159 e->type = ue->type; 160 e->type = ue->type;
160 r = kvm_set_routing_entry(kvm, e, ue); 161 r = kvm_set_routing_entry(kvm, e, ue);
161 if (r) 162 if (r)