In theory, if the interrupt handle setup fails, an eventfd gets leaked.
In practice, as long as the interrupt handle is valid, those calls can
not fail, but this could get broken in the future so it is better to
handle this error branch correctly.
Fixes: d61138d4f0e2 ("drivers: remove direct access to interrupt handle")
Signed-off-by: David Marchand <[email protected]>
---
drivers/bus/dpaa/dpaa_bus.c | 11 +++++++----
drivers/bus/fslmc/fslmc_vfio.c | 18 ++++++++++--------
2 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index 06962a5b29..5df2dff8f2 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -648,11 +648,14 @@ static int rte_dpaa_setup_intr(struct rte_intr_handle
*intr_handle)
return errno;
}
- if (rte_intr_fd_set(intr_handle, fd))
- return rte_errno;
+ if (rte_intr_fd_set(intr_handle, fd) ||
+ rte_intr_type_set(intr_handle, RTE_INTR_HANDLE_EXT)) {
+ int err = rte_errno;
- if (rte_intr_type_set(intr_handle, RTE_INTR_HANDLE_EXT))
- return rte_errno;
+ close(fd);
+ rte_intr_fd_set(intr_handle, -1);
+ return err;
+ }
return 0;
}
diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 412b70e5ae..165e9444f5 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -1371,14 +1371,16 @@ rte_dpaa2_vfio_setup_intr(struct rte_intr_handle
*intr_handle,
return fd;
}
- if (rte_intr_fd_set(intr_handle, fd))
- return -rte_errno;
-
- if (rte_intr_type_set(intr_handle, RTE_INTR_HANDLE_VFIO_MSI))
- return -rte_errno;
-
- if (rte_intr_dev_fd_set(intr_handle, vfio_dev_fd))
- return -rte_errno;
+ if (rte_intr_fd_set(intr_handle, fd) ||
+ rte_intr_type_set(intr_handle,
RTE_INTR_HANDLE_VFIO_MSI) ||
+ rte_intr_dev_fd_set(intr_handle, vfio_dev_fd)) {
+ int error = -rte_errno;
+
+ close(fd);
+ rte_intr_fd_set(intr_handle, -1);
+ rte_intr_dev_fd_set(intr_handle, -1);
+ return error;
+ }
return 0;
}
--
2.54.0