[RFC v3 2/5] eal/freebsd: fix a FD leak in the alarm subsystem
Bruce Richardson
bruce.richardson at intel.com
Mon Sep 7 14:35:37 CEST 2026
On Mon, Sep 07, 2026 at 02:13:45PM +0200, David Marchand wrote:
> Caught by code review, while looking at rte_intr_instance_free() users.
>
> Even if the FD is not used, it must still be closed when uninitialising
> the alarm subsystem.
>
> Fixes: 26021a715067 ("eal/bsd: support alarm API")
> Cc: stable at dpdk.org
>
> Signed-off-by: David Marchand <david.marchand at redhat.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
> lib/eal/freebsd/eal_alarm.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/lib/eal/freebsd/eal_alarm.c b/lib/eal/freebsd/eal_alarm.c
> index c03e281e67..2905841b5e 100644
> --- a/lib/eal/freebsd/eal_alarm.c
> +++ b/lib/eal/freebsd/eal_alarm.c
> @@ -54,6 +54,8 @@ rte_eal_alarm_cleanup(void)
> int ret = rte_intr_callback_unregister_sync(intr_handle,
> eal_alarm_callback, (void *)-1);
> if (ret >= 0) {
> + close(rte_intr_fd_get(intr_handle));
> + rte_intr_fd_set(intr_handle, -1);
> rte_intr_instance_free(intr_handle);
> intr_handle = NULL;
> }
> @@ -62,7 +64,7 @@ rte_eal_alarm_cleanup(void)
> int
> rte_eal_alarm_init(void)
> {
> - int fd;
> + int fd = -1;
>
> intr_handle = rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE);
> if (intr_handle == NULL) {
> @@ -88,6 +90,8 @@ rte_eal_alarm_init(void)
>
> return 0;
> error:
> + if (fd >= 0)
> + close(fd);
> rte_intr_instance_free(intr_handle);
> return -1;
> }
> --
> 2.54.0
>
More information about the dev
mailing list