[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/12] msi: fix MSI vector limit check in msi_set_mask()
From: |
Michael S. Tsirkin |
Subject: |
[PULL 02/12] msi: fix MSI vector limit check in msi_set_mask() |
Date: |
Tue, 28 Jun 2022 00:42:30 -0400 |
From: Jagannathan Raman <jag.raman@oracle.com>
MSI supports a maximum of PCI_MSI_VECTORS_MAX vectors - from 0 to
PCI_MSI_VECTORS_MAX - 1.
msi_set_mask() was previously using PCI_MSI_VECTORS_MAX as the upper
limit for MSI vectors. Fix the upper limit to PCI_MSI_VECTORS_MAX - 1.
Fixes: Coverity CID 1490141
Fixes: 08cf3dc61199 vfio-user: handle device interrupts
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
Message-Id: <20220623153844.7367-1-jag.raman@oracle.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/pci/msi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/pci/msi.c b/hw/pci/msi.c
index 5c471b9616..058d1d1ef1 100644
--- a/hw/pci/msi.c
+++ b/hw/pci/msi.c
@@ -322,9 +322,9 @@ void msi_set_mask(PCIDevice *dev, int vector, bool mask,
Error **errp)
bool msi64bit = flags & PCI_MSI_FLAGS_64BIT;
uint32_t irq_state, vector_mask, pending;
- if (vector > PCI_MSI_VECTORS_MAX) {
+ if (vector >= PCI_MSI_VECTORS_MAX) {
error_setg(errp, "msi: vector %d not allocated. max vector is %d",
- vector, PCI_MSI_VECTORS_MAX);
+ vector, (PCI_MSI_VECTORS_MAX - 1));
return;
}
--
MST
- [PULL 00/12] virtio: fixes, Michael S. Tsirkin, 2022/06/28
- [PULL 02/12] msi: fix MSI vector limit check in msi_set_mask(),
Michael S. Tsirkin <=
- [PULL 03/12] vhost: add method vhost_set_vring_err, Michael S. Tsirkin, 2022/06/28
- [PULL 04/12] vhost: setup error eventfd and dump errors, Michael S. Tsirkin, 2022/06/28
- [PULL 01/12] virtio-iommu: Fix the partial copy of probe request, Michael S. Tsirkin, 2022/06/28
- [PULL 05/12] virtio-iommu: Fix migration regression, Michael S. Tsirkin, 2022/06/28
- [PULL 06/12] docs/vhost-user: Fix mismerge, Michael S. Tsirkin, 2022/06/28
- [PULL 07/12] libvhost-user: Fix VHOST_USER_GET_MAX_MEM_SLOTS reply, Michael S. Tsirkin, 2022/06/28
- [PULL 09/12] MAINTAINERS: Collect memory device files in "Memory devices", Michael S. Tsirkin, 2022/06/28
- [PULL 11/12] include/hw/virtio: document vhost_get_features, Michael S. Tsirkin, 2022/06/28
- [PULL 12/12] include/hw/virtio: document vhost_ack_features, Michael S. Tsirkin, 2022/06/28
- [PULL 10/12] contrib/vhost-user-blk: fix 32 bit build and enable, Michael S. Tsirkin, 2022/06/28