msi: fix MSI vector limit check in msi_set_mask()
PATCH 1/1 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 <[email protected]>
--- hw/pci/msi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/pci/msi.c +2 -2
@@ -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 ; }
Signature · 1 line
2.20.1
Reviewed-by Stefan Hajnoczi <[email protected]>
Quoted 35 lines · Jagannathan Raman
MSI supports a maximum of
PCI_MSI_VECTORS_MAXvectors - from 0 toPCI_MSI_VECTORS_MAX- 1.
msi_set_mask()was previously usingPCI_MSI_VECTORS_MAXas the upper limit for MSI vectors. Fix the upper limit toPCI_MSI_VECTORS_MAX- 1.Fixes Coverity CID 1490141Fixes 08cf3dc61199 vfio-user: handle device interruptsSigned-off-by Jagannathan Raman <[email protected]>--- hw/pci/msi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/pci/msi.c +2
-3@@ -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 ; } --2.20.1