Fix: sessiond: kernel: close on badfd on initialization error
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 29 Mar 2021 16:17:12 +0000 (12:17 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 31 Mar 2021 23:18:56 +0000 (19:18 -0400)
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 <jeremie.galarneau@efficios.com>
Change-Id: I11d3ce7accea51394c34b9ca7ea0445e4ee422fc

src/bin/lttng-sessiond/kernel.c

index eebe119d2701dc8e3875c9f5e2f482a0849fd452..b431b3dfb6e935ddf068e80e6dd4097d378a0784 100644 (file)
@@ -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();
 
This page took 0.027662 seconds and 4 git commands to generate.