* [PATCH] msi: fix MSI vector limit check in msi_set_mask()
@ 2022-06-23 15:38 Jagannathan Raman
2022-06-24 15:10 ` Stefan Hajnoczi
0 siblings, 1 reply; 2+ messages in thread
From: Jagannathan Raman @ 2022-06-23 15:38 UTC (permalink / raw)
To: qemu-devel; +Cc: stefanha, mst, marcel.apfelbaum
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>
---
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;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] msi: fix MSI vector limit check in msi_set_mask()
2022-06-23 15:38 [PATCH] msi: fix MSI vector limit check in msi_set_mask() Jagannathan Raman
@ 2022-06-24 15:10 ` Stefan Hajnoczi
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2022-06-24 15:10 UTC (permalink / raw)
To: Jagannathan Raman
Cc: qemu-devel, Stefan Hajnoczi, Michael S. Tsirkin, Marcel Apfelbaum
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
On Thu, 23 Jun 2022 at 16:42, Jagannathan Raman <jag.raman@oracle.com> wrote:
>
> 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>
> ---
> 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;
> }
>
> --
> 2.20.1
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-24 15:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-23 15:38 [PATCH] msi: fix MSI vector limit check in msi_set_mask() Jagannathan Raman
2022-06-24 15:10 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).