Skip to content

Commit

Permalink
vfio/pci: Move to single error path
Browse files Browse the repository at this point in the history
Enabling and disabling of an interrupt involves several steps
that can fail. Cleanup after failure is done when the error
is encountered, resulting in some repetitive code.

Support for dynamic contexts will introduce more steps during
interrupt enabling and disabling.

Transition to centralized exit path in preparation for dynamic
contexts to eliminate duplicate error handling code.

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/72dddae8aa710ce522a74130120733af61cffe4d.1683740667.git.reinette.chatre@intel.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
  • Loading branch information
Reinette Chatre authored and Alex Williamson committed May 23, 2023
1 parent d977e0f commit 8850336
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions drivers/vfio/pci/vfio_pci_intrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_core_device *vdev,

trigger = eventfd_ctx_fdget(fd);
if (IS_ERR(trigger)) {
kfree(ctx->name);
return PTR_ERR(trigger);
ret = PTR_ERR(trigger);
goto out_free_name;
}

/*
Expand All @@ -448,11 +448,8 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_core_device *vdev,

ret = request_irq(irq, vfio_msihandler, 0, ctx->name, trigger);
vfio_pci_memory_unlock_and_restore(vdev, cmd);
if (ret) {
kfree(ctx->name);
eventfd_ctx_put(trigger);
return ret;
}
if (ret)
goto out_put_eventfd_ctx;

ctx->producer.token = trigger;
ctx->producer.irq = irq;
Expand All @@ -467,6 +464,12 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_core_device *vdev,
ctx->trigger = trigger;

return 0;

out_put_eventfd_ctx:
eventfd_ctx_put(trigger);
out_free_name:
kfree(ctx->name);
return ret;
}

static int vfio_msi_set_block(struct vfio_pci_core_device *vdev, unsigned start,
Expand Down

0 comments on commit 8850336

Please sign in to comment.