mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
vfio/pci: Remove negative check on unsigned vector
[ Upstream commit 6578ed85c7 ]
User space provides the vector as an unsigned int that is checked
early for validity (vfio_set_irqs_validate_and_prepare()).
A later negative check of the provided vector is not necessary.
Remove the negative check and ensure the type used
for the vector is consistent as an unsigned int.
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/28521e1b0b091849952b0ecb8c118729fc8cdc4f.1683740667.git.reinette.chatre@intel.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Stable-dep-of: fe9a7082684e ("vfio/pci: Disable auto-enable of exclusive INTx IRQ")
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
dcc6b99c61
commit
f56ba2d484
@@ -317,14 +317,14 @@ static int vfio_msi_enable(struct vfio_pci_core_device *vdev, int nvec, bool msi
|
||||
}
|
||||
|
||||
static int vfio_msi_set_vector_signal(struct vfio_pci_core_device *vdev,
|
||||
int vector, int fd, bool msix)
|
||||
unsigned int vector, int fd, bool msix)
|
||||
{
|
||||
struct pci_dev *pdev = vdev->pdev;
|
||||
struct eventfd_ctx *trigger;
|
||||
int irq, ret;
|
||||
u16 cmd;
|
||||
|
||||
if (vector < 0 || vector >= vdev->num_ctx)
|
||||
if (vector >= vdev->num_ctx)
|
||||
return -EINVAL;
|
||||
|
||||
irq = pci_irq_vector(pdev, vector);
|
||||
@@ -399,7 +399,8 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_core_device *vdev,
|
||||
static int vfio_msi_set_block(struct vfio_pci_core_device *vdev, unsigned start,
|
||||
unsigned count, int32_t *fds, bool msix)
|
||||
{
|
||||
int i, j, ret = 0;
|
||||
unsigned int i, j;
|
||||
int ret = 0;
|
||||
|
||||
if (start >= vdev->num_ctx || start + count > vdev->num_ctx)
|
||||
return -EINVAL;
|
||||
@@ -410,8 +411,8 @@ static int vfio_msi_set_block(struct vfio_pci_core_device *vdev, unsigned start,
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
for (--j; j >= (int)start; j--)
|
||||
vfio_msi_set_vector_signal(vdev, j, -1, msix);
|
||||
for (i = start; i < j; i++)
|
||||
vfio_msi_set_vector_signal(vdev, i, -1, msix);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -420,7 +421,7 @@ static int vfio_msi_set_block(struct vfio_pci_core_device *vdev, unsigned start,
|
||||
static void vfio_msi_disable(struct vfio_pci_core_device *vdev, bool msix)
|
||||
{
|
||||
struct pci_dev *pdev = vdev->pdev;
|
||||
int i;
|
||||
unsigned int i;
|
||||
u16 cmd;
|
||||
|
||||
for (i = 0; i < vdev->num_ctx; i++) {
|
||||
@@ -542,7 +543,7 @@ static int vfio_pci_set_msi_trigger(struct vfio_pci_core_device *vdev,
|
||||
unsigned index, unsigned start,
|
||||
unsigned count, uint32_t flags, void *data)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
bool msix = (index == VFIO_PCI_MSIX_IRQ_INDEX) ? true : false;
|
||||
|
||||
if (irq_is(vdev, index) && !count && (flags & VFIO_IRQ_SET_DATA_NONE)) {
|
||||
|
||||
Reference in New Issue
Block a user