From: Jérémie Galarneau Date: Mon, 29 Mar 2021 16:17:12 +0000 (-0400) Subject: Fix: sessiond: kernel: close on badfd on initialization error X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=6dcf80d3521804571f64844853d976d6fe16ebc7;p=lttng-tools.git Fix: sessiond: kernel: close on badfd on initialization error The various kernel tracer file descriptors are closed during an initialization error, but are not set to `-1` which causes them to be closed again when the session daemon performs its clean-up. Signed-off-by: Jérémie Galarneau Change-Id: I11d3ce7accea51394c34b9ca7ea0445e4ee422fc --- diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index eebe119d2..b431b3dfb 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -2036,6 +2036,7 @@ error_version: PERROR("Failed to close kernel tracer file descriptor: fd = %d", kernel_tracer_fd); } + kernel_tracer_fd = -1; return LTTNG_ERR_KERN_VERSION; @@ -2047,6 +2048,8 @@ error_token_ht: kernel_tracer_event_notifier_group_notification_fd); } + kernel_tracer_event_notifier_group_notification_fd = -1; + error_modules: ret = close(kernel_tracer_event_notifier_group_fd); if (ret) { @@ -2054,12 +2057,16 @@ error_modules: kernel_tracer_event_notifier_group_fd); } + kernel_tracer_event_notifier_group_fd = -1; + ret = close(kernel_tracer_fd); if (ret) { PERROR("Failed to close kernel tracer file descriptor: fd = %d", kernel_tracer_fd); } + kernel_tracer_fd = -1; + error_open: modprobe_remove_lttng_control();