From 0ae00cbb9edcc3879b1276cd61479d668a7f1ec9 Mon Sep 17 00:00:00 2001 From: Thanos Makatos Date: Mon, 29 Mar 2021 17:34:34 +0100 Subject: don't access invalid array index (#405) Signed-off-by: Thanos Makatos Reviewed-by: John Levon --- lib/irq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/irq.c b/lib/irq.c index 7ea0349..3da1fb8 100644 --- a/lib/irq.c +++ b/lib/irq.c @@ -102,18 +102,18 @@ irqs_disable(vfu_ctx_t *vfu_ctx, uint32_t index, uint32_t start, uint32_t count) assert(index < VFU_DEV_NUM_IRQS); assert(start + count <= vfu_ctx->irq_count[index]); - vfu_log(vfu_ctx, LOG_DEBUG, "disabling IRQ type %s range [%u-%u)", - vfio_irq_idx_to_str(index), start, start + count); - if (count == 0) { count = vfu_ctx->irq_count[index]; } + vfu_log(vfu_ctx, LOG_DEBUG, "disabling IRQ type %s range [%u-%u)", + vfio_irq_idx_to_str(index), start, start + count); + switch (index) { case VFIO_PCI_INTX_IRQ_INDEX: case VFIO_PCI_MSI_IRQ_INDEX: case VFIO_PCI_MSIX_IRQ_INDEX: - efds = vfu_ctx->irqs[index].efds; + efds = vfu_ctx->irqs->efds; break; case VFIO_PCI_ERR_IRQ_INDEX: efds = &vfu_ctx->irqs->err_efd; -- cgit v1.1