Fix metadata event arg (null pointer exception)
[lttng-modules.git] / ltt-debugfs-abi.c
index 9139e5a1751f8ba56ea48c2676d6480d8c08a779..02f7232ccb67f2b89ac9d446f14bb2daf043d123 100644 (file)
@@ -142,6 +142,10 @@ static
 void lttng_metadata_create_events(struct file *channel_file)
 {
        struct ltt_channel *channel = channel_file->private_data;
+       static struct lttng_kernel_event metadata_params = {
+               .instrumentation = LTTNG_KERNEL_TRACEPOINTS,
+               .name = "lttng_metadata",
+       };
        char *event_name = "lttng_metadata";
        struct ltt_event *event;
        int ret;
@@ -150,8 +154,7 @@ void lttng_metadata_create_events(struct file *channel_file)
         * We tolerate no failure path after event creation. It will stay
         * invariant for the rest of the session.
         */
-       event = ltt_event_create(channel, event_name, LTTNG_KERNEL_TRACEPOINTS,
-                                NULL);
+       event = ltt_event_create(channel, event_name, &metadata_params, NULL);
        if (!event) {
                goto create_error;
                ret = -EEXIST;
@@ -222,8 +225,8 @@ int lttng_abi_create_channel(struct file *session_file,
        chan_file->private_data = chan;
        fd_install(chan_fd, chan_file);
        if (channel_type == METADATA_CHANNEL) {
-               lttng_metadata_create_events(chan_file);
                session->metadata = chan;
+               lttng_metadata_create_events(chan_file);
        }
 
        /* The channel created holds a reference on the session */
@@ -367,8 +370,16 @@ int lttng_abi_create_event(struct file *channel_file,
                goto name_error;
        }
        event_name[PATH_MAX - 1] = '\0';
-       event_param.u.kprobe.symbol_name[LTTNG_KPROBE_SYM_NAME_LEN - 1] = '\0';
-
+       switch (event_param.instrumentation) {
+       case LTTNG_KERNEL_KPROBES:
+               event_param.u.kprobe.symbol_name[LTTNG_SYM_NAME_LEN - 1] = '\0';
+               break;
+       case LTTNG_KERNEL_FUNCTION_TRACER:
+               event_param.u.ftrace.symbol_name[LTTNG_SYM_NAME_LEN - 1] = '\0';
+               break;
+       default:
+               break;
+       }
        event_fd = get_unused_fd();
        if (event_fd < 0) {
                ret = event_fd;
This page took 0.023738 seconds and 4 git commands to generate.