Fix: lttng-sessiond: kernel: leak of event notifier rule
[lttng-tools.git] / src / bin / lttng-sessiond / kernel.c
index 54e745474d89c8c891bc78f8a35b8ce742f53cd0..03a358a0d3f1da9478ef220c3e93309298b469f7 100644 (file)
 
 #include <lttng/userspace-probe.h>
 #include <lttng/userspace-probe-internal.h>
-#include <lttng/condition/event-rule.h>
-#include <lttng/condition/event-rule-internal.h>
+#include <lttng/condition/on-event.h>
+#include <lttng/condition/on-event-internal.h>
 #include <lttng/event-rule/event-rule.h>
 #include <lttng/event-rule/event-rule-internal.h>
-#include <lttng/event-rule/uprobe-internal.h>
+#include <lttng/event-rule/userspace-probe-internal.h>
 
 #include "lttng-sessiond.h"
 #include "lttng-syscall.h"
@@ -540,9 +540,9 @@ static int userspace_probe_event_rule_add_callsites(
        assert(creds);
 
        event_rule_type = lttng_event_rule_get_type(rule);
-       assert(event_rule_type == LTTNG_EVENT_RULE_TYPE_UPROBE);
+       assert(event_rule_type == LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE);
 
-       status = lttng_event_rule_uprobe_get_location(rule, &location);
+       status = lttng_event_rule_userspace_probe_get_location(rule, &location);
        if (status != LTTNG_EVENT_RULE_STATUS_OK || !location) {
                ret = -1;
                goto end;
@@ -2310,10 +2310,10 @@ static enum lttng_error_code kernel_create_event_notifier_rule(
        assert(condition);
 
        condition_type = lttng_condition_get_type(condition);
-       assert(condition_type == LTTNG_CONDITION_TYPE_EVENT_RULE_HIT);
+       assert(condition_type == LTTNG_CONDITION_TYPE_ON_EVENT);
 
        /* Does not acquire a reference. */
-       condition_status = lttng_condition_event_rule_get_rule(
+       condition_status = lttng_condition_on_event_get_rule(
                        condition, &event_rule);
        assert(condition_status == LTTNG_CONDITION_STATUS_OK);
        assert(event_rule);
@@ -2386,7 +2386,7 @@ static enum lttng_error_code kernel_create_event_notifier_rule(
        }
 
        if (lttng_event_rule_get_type(event_rule) ==
-                       LTTNG_EVENT_RULE_TYPE_UPROBE) {
+                       LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE) {
                ret = userspace_probe_event_rule_add_callsites(
                                event_rule, creds, event_notifier_rule->fd);
                if (ret) {
@@ -2395,20 +2395,20 @@ static enum lttng_error_code kernel_create_event_notifier_rule(
                }
        }
 
-       /* Set the capture bytecode, if any. */
-       cond_status = lttng_condition_event_rule_get_capture_descriptor_count(
+       /* Set the capture bytecode if any. */
+       cond_status = lttng_condition_on_event_get_capture_descriptor_count(
                        condition, &capture_bytecode_count);
        assert(cond_status == LTTNG_CONDITION_STATUS_OK);
 
        for (i = 0; i < capture_bytecode_count; i++) {
                const struct lttng_bytecode *capture_bytecode =
-                               lttng_condition_event_rule_get_capture_bytecode_at_index(
+                               lttng_condition_on_event_get_capture_bytecode_at_index(
                                                condition, i);
 
                if (capture_bytecode == NULL) {
                        ERR("Unexpected NULL capture bytecode on condition");
                        error_code_ret = LTTNG_ERR_KERN_ENABLE_FAIL;
-                       goto error;
+                       goto capture_error;
                }
 
                ret = kernctl_capture(event_notifier_rule->fd, capture_bytecode);
@@ -2416,7 +2416,7 @@ static enum lttng_error_code kernel_create_event_notifier_rule(
                        ERR("Failed to set capture bytecode on event notifier rule fd: fd = %d",
                                        event_notifier_rule->fd);
                        error_code_ret = LTTNG_ERR_KERN_ENABLE_FAIL;
-                       goto error;
+                       goto capture_error;
                }
        }
 
@@ -2446,6 +2446,7 @@ static enum lttng_error_code kernel_create_event_notifier_rule(
 
        return LTTNG_OK;
 
+capture_error:
 add_callsite_error:
 enable_error:
 set_cloexec_error:
@@ -2479,7 +2480,7 @@ enum lttng_error_code kernel_register_event_notifier(
        assert(condition);
 
        /* Does not acquire a reference to the event rule. */
-       status = lttng_condition_event_rule_get_rule(
+       status = lttng_condition_on_event_get_rule(
                        condition, &event_rule);
        assert(status == LTTNG_CONDITION_STATUS_OK);
 
This page took 0.02519 seconds and 4 git commands to generate.