Fix: leak of event attributes on copy failure
[lttng-tools.git] / src / bin / lttng-sessiond / main.c
index 958aa0d04f0830385b9ad215fb38219489ce0847..d8ea2c1a5b2640af24864c6d12d6c91c8dd78001 100644 (file)
@@ -51,6 +51,7 @@
 #include <common/config/session-config.h>
 #include <common/dynamic-buffer.h>
 #include <lttng/userspace-probe-internal.h>
+#include <lttng/event-internal.h>
 
 #include "lttng-sessiond.h"
 #include "buffer-registry.h"
@@ -2501,7 +2502,8 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data)
                        } else if (stat(INSTALL_BIN_PATH "/" DEFAULT_CONSUMERD_FILE, &st) == 0) {
                                DBG3("Found location #2");
                                consumer_to_use = INSTALL_BIN_PATH "/" DEFAULT_CONSUMERD_FILE;
-                       } else if (stat(config.consumerd32_bin_path.value, &st) == 0) {
+                       } else if (config.consumerd32_bin_path.value &&
+                                       stat(config.consumerd32_bin_path.value, &st) == 0) {
                                DBG3("Found location #3");
                                consumer_to_use = config.consumerd32_bin_path.value;
                        } else {
@@ -2937,7 +2939,7 @@ static int receive_userspace_probe(struct command_ctx *cmd_ctx, int sock,
 {
        int fd, ret;
        struct lttng_userspace_probe_location *probe_location;
-       struct lttng_userspace_probe_location_lookup_method *lookup = NULL;
+       const struct lttng_userspace_probe_location_lookup_method *lookup = NULL;
        struct lttng_dynamic_buffer probe_location_buffer;
        struct lttng_buffer_view buffer_view;
 
@@ -3100,7 +3102,6 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock,
        case LTTNG_UNREGISTER_TRIGGER:
        case LTTNG_ROTATE_SESSION:
        case LTTNG_ROTATION_GET_INFO:
-       case LTTNG_SESSION_GET_CURRENT_OUTPUT:
        case LTTNG_ROTATION_SET_SCHEDULE:
        case LTTNG_SESSION_LIST_ROTATION_SCHEDULES:
                need_domain = 0;
@@ -3682,6 +3683,9 @@ error_add_context:
                if (!ev) {
                        DBG("Failed to copy event: %s",
                                        cmd_ctx->lsm->u.enable.event.name);
+                       free(filter_expression);
+                       free(bytecode);
+                       free(exclusion);
                        ret = LTTNG_ERR_NOMEM;
                        goto error;
                }
@@ -3691,6 +3695,9 @@ error_add_context:
                        /* Expect a userspace probe description. */
                        ret = receive_userspace_probe(cmd_ctx, sock, sock_error, ev);
                        if (ret) {
+                               free(filter_expression);
+                               free(bytecode);
+                               free(exclusion);
                                lttng_event_destroy(ev);
                                goto error;
                        }
@@ -4322,28 +4329,6 @@ error_add_context:
                ret = LTTNG_OK;
                break;
        }
-       case LTTNG_SESSION_GET_CURRENT_OUTPUT:
-       {
-               struct lttng_session_get_current_output_return output_return;
-
-               memset(&output_return, 0, sizeof(output_return));
-               ret = cmd_session_get_current_output(cmd_ctx->session,
-                               &output_return);
-               if (ret < 0) {
-                       ret = -ret;
-                       goto error;
-               }
-
-               ret = setup_lttng_msg_no_cmd_header(cmd_ctx, &output_return,
-                               sizeof(output_return));
-               if (ret < 0) {
-                       ret = -ret;
-                       goto error;
-               }
-
-               ret = LTTNG_OK;
-               break;
-       }
        case LTTNG_ROTATION_SET_SCHEDULE:
        {
                bool set_schedule;
This page took 0.025727 seconds and 5 git commands to generate.