aboutsummaryrefslogtreecommitdiff
path: root/hw/pci
diff options
context:
space:
mode:
authorJagannathan Raman <jag.raman@oracle.com>2022-06-23 11:38:44 -0400
committerMichael S. Tsirkin <mst@redhat.com>2022-06-27 18:53:18 -0400
commit71e3d004824724fe55cd1c4dba34477361a38319 (patch)
tree09e38064c8df63fcd7eb475a0dfd6a91bd4ec1e1 /hw/pci
parent45461aace83d961e933b27519b81d17b4c690514 (diff)
msi: fix MSI vector limit check in msi_set_mask()
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>
Diffstat (limited to 'hw/pci')
-rw-r--r--hw/pci/msi.c4
1 files 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;
}