Fix OOPS caused by reference of config pointer
[lttng-modules.git] / lttng-context-pid.c
index ddd78a5d8dfb3f4b4e0eb296286a8c6d1a8cde3f..698b242245a28b6e38484f65f21f129e53ab9774 100644 (file)
@@ -32,7 +32,7 @@ void pid_record(struct lttng_ctx_field *field,
 {
        pid_t pid;
 
-       pid = current->pid;
+       pid = task_tgid_nr(current);
        lib_ring_buffer_align_ctx(ctx, ltt_alignof(pid));
        chan->ops->event_write(ctx, &pid, sizeof(pid));
 }
@@ -40,11 +40,14 @@ void pid_record(struct lttng_ctx_field *field,
 int lttng_add_pid_to_ctx(struct lttng_ctx **ctx)
 {
        struct lttng_ctx_field *field;
-       int ret;
 
        field = lttng_append_context(ctx);
        if (!field)
-               return ret;
+               return -ENOMEM;
+       if (lttng_find_context(*ctx, "pid")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
        field->event_field.name = "pid";
        field->event_field.type.atype = atype_integer;
        field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
This page took 0.023163 seconds and 4 git commands to generate.