Both wrappers of vfio_pci_set_ctx_trigger_single() perform the same parameter checks before calling vfio_pci_set_ctx_trigger_single(). vfio_pci_set_ctx_trigger_single() only handles a single interrupt that is expected to start from 0. Move parameter checks into vfio_pci_set_ctx_trigger_single() instead of duplicated in its callers. Signed-off-by: Reinette Chatre <reinette.chatre@xxxxxxxxx> --- drivers/vfio/pci/vfio_pci_intrs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c index f9280e32972a..69ab11863282 100644 --- a/drivers/vfio/pci/vfio_pci_intrs.c +++ b/drivers/vfio/pci/vfio_pci_intrs.c @@ -704,9 +704,13 @@ static int vfio_pci_set_msi_trigger(struct vfio_pci_core_device *vdev, } static int vfio_pci_set_ctx_trigger_single(struct eventfd_ctx **ctx, + unsigned int start, unsigned int count, uint32_t flags, void *data) { + if (start != 0 || count > 1) + return -EINVAL; + /* DATA_NONE/DATA_BOOL enables loopback testing */ if (flags & VFIO_IRQ_SET_DATA_NONE) { if (*ctx) { @@ -763,10 +767,10 @@ static int vfio_pci_set_err_trigger(struct vfio_pci_core_device *vdev, unsigned int count, uint32_t flags, void *data) { - if (index != VFIO_PCI_ERR_IRQ_INDEX || start != 0 || count > 1) + if (index != VFIO_PCI_ERR_IRQ_INDEX) return -EINVAL; - return vfio_pci_set_ctx_trigger_single(&vdev->err_trigger, + return vfio_pci_set_ctx_trigger_single(&vdev->err_trigger, start, count, flags, data); } @@ -775,10 +779,10 @@ static int vfio_pci_set_req_trigger(struct vfio_pci_core_device *vdev, unsigned int count, uint32_t flags, void *data) { - if (index != VFIO_PCI_REQ_IRQ_INDEX || start != 0 || count > 1) + if (index != VFIO_PCI_REQ_IRQ_INDEX) return -EINVAL; - return vfio_pci_set_ctx_trigger_single(&vdev->req_trigger, + return vfio_pci_set_ctx_trigger_single(&vdev->req_trigger, start, count, flags, data); } -- 2.34.1