Fix: ownership of filter and filter_expression
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 6 Apr 2015 16:17:20 +0000 (12:17 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 7 Apr 2015 15:04:47 +0000 (11:04 -0400)
Applies to the kernel wildcard feature.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/event.c
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/trace-kernel.c

index 95e371d7b66fe527da607a7c60d0c49b871a2e63..a6ce344a483d11642bf751aae9fad1565aa46afd 100644 (file)
@@ -1512,6 +1512,9 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
                        event->type = LTTNG_EVENT_TRACEPOINT;   /* Hack */
                        ret = event_kernel_enable_event(kchan, event,
                                filter_expression, filter);
+                       /* We have passed ownership */
+                       filter_expression = NULL;
+                       filter = NULL;
                        if (ret != LTTNG_OK) {
                                if (channel_created) {
                                        /* Let's not leak a useless channel. */
@@ -1537,6 +1540,9 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
                case LTTNG_EVENT_TRACEPOINT:
                        ret = event_kernel_enable_event(kchan, event,
                                filter_expression, filter);
+                       /* We have passed ownership */
+                       filter_expression = NULL;
+                       filter = NULL;
                        if (ret != LTTNG_OK) {
                                if (channel_created) {
                                        /* Let's not leak a useless channel. */
@@ -1548,6 +1554,9 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
                case LTTNG_EVENT_SYSCALL:
                        ret = event_kernel_enable_event(kchan, event,
                                filter_expression, filter);
+                       /* We have passed ownership */
+                       filter_expression = NULL;
+                       filter = NULL;
                        if (ret != LTTNG_OK) {
                                goto error;
                        }
index 32efcdbf210ee5d5a2b5d99cdfcf2a2a2f1e4279..bedaa2e2f4e220e63c6458a1c7947aaa9081b3a3 100644 (file)
@@ -143,6 +143,9 @@ int event_kernel_enable_event(struct ltt_kernel_channel *kchan,
        if (kevent == NULL) {
                ret = kernel_create_event(event, kchan,
                        filter_expression, filter);
+               /* We have passed ownership */
+               filter_expression = NULL;
+               filter = NULL;
                if (ret < 0) {
                        switch (-ret) {
                        case EEXIST:
@@ -171,6 +174,8 @@ int event_kernel_enable_event(struct ltt_kernel_channel *kchan,
 
        ret = LTTNG_OK;
 end:
+       free(filter_expression);
+       free(filter);
        return ret;
 }
 
index 45d958546f2cae75d938a8960af3c3fd5690be64..570747f183ac96f479fd0a7480919b27345221bd 100644 (file)
@@ -187,6 +187,7 @@ int kernel_create_event(struct lttng_event *ev,
        assert(ev);
        assert(channel);
 
+       /* We pass ownership of filter_expression and filter */
        event = trace_kernel_create_event(ev, filter_expression,
                        filter);
        if (event == NULL) {
index 33a9e7e5578daf8454e5ccc97bc3d97d85e7934f..b86bdfe6060b37c0698f805f2daa89491d54101d 100644 (file)
@@ -258,6 +258,7 @@ error:
 
 /*
  * Allocate and initialize a kernel event. Set name and event type.
+ * We own filter_expression, and filter.
  *
  * Return pointer to structure or NULL.
  */
@@ -327,6 +328,8 @@ struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev,
        return lke;
 
 error:
+       free(filter_expression);
+       free(filter);
        free(lke);
        free(attr);
        return NULL;
This page took 0.030542 seconds and 4 git commands to generate.