Fix: ensure kernel context is in a list before trying to delete it
[lttng-tools.git] / src / bin / lttng-sessiond / kernel.c
index b32193451f2060c401ac9d7503f2e48574be3fe4..2cbed381870a096350a4e8ac77ec39845850d0f1 100644 (file)
@@ -36,6 +36,8 @@
 
 /*
  * Add context on a kernel channel.
+ *
+ * Assumes the ownership of ctx.
  */
 int kernel_add_channel_context(struct ltt_kernel_channel *chan,
                struct ltt_kernel_context *ctx)
@@ -63,12 +65,16 @@ int kernel_add_channel_context(struct ltt_kernel_channel *chan,
                        goto error;
                }
        }
+       ret = 0;
 
 end:
        cds_list_add_tail(&ctx->list, &chan->ctx_list);
-       return 0;
-
+       ctx->in_list = true;
+       ctx = NULL;
 error:
+       if (ctx) {
+               trace_kernel_destroy_context(ctx);
+       }
        return ret;
 }
 
This page took 0.023096 seconds and 4 git commands to generate.