Fix: Uninitialized pointer read
[lttng-tools.git] / src / bin / lttng-sessiond / main.c
index 2cb8f5a23e77b267b37dc513d5dccb8bdc994c40..efaaf4ffa99f40c5cc0dac877e796a7eda86e5ea 100644 (file)
@@ -3097,6 +3097,10 @@ static void *thread_manage_health(void *data)
 
        rcu_register_thread();
 
+       /* We might hit an error path before this is set once. */
+       memset(&events, 0, sizeof(events));
+       events.epfd = -1;
+
        /* Create unix socket */
        sock = lttcomm_create_unix_sock(health_unix_sock_path);
        if (sock < 0) {
@@ -3449,13 +3453,11 @@ static void *thread_manage_clients(void *data)
                ret = process_client_msg(cmd_ctx, sock, &sock_error);
                rcu_thread_offline();
                if (ret < 0) {
-                       if (sock_error) {
-                               ret = close(sock);
-                               if (ret) {
-                                       PERROR("close");
-                               }
-                               sock = -1;
+                       ret = close(sock);
+                       if (ret) {
+                               PERROR("close");
                        }
+                       sock = -1;
                        /*
                         * TODO: Inform client somehow of the fatal error. At
                         * this point, ret < 0 means that a zmalloc failed
This page took 0.026386 seconds and 5 git commands to generate.