From: Jérémie Galarneau Date: Wed, 2 Aug 2017 20:49:44 +0000 (-0400) Subject: Fix: ensure kernel context is in a list before trying to delete it X-Git-Tag: v2.8.8~2 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=bf82eb3cf93a9f1823493a09ce612c578f1435d7;p=lttng-tools.git Fix: ensure kernel context is in a list before trying to delete it Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index 8dc3f8631..c99c6fd1b 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -69,6 +69,7 @@ int kernel_add_channel_context(struct ltt_kernel_channel *chan, end: cds_list_add_tail(&ctx->list, &chan->ctx_list); + ctx->in_list = true; ctx = NULL; error: if (ctx) { diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index ce5aca2ed..fa207bc67 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -484,7 +484,9 @@ void trace_kernel_destroy_context(struct ltt_kernel_context *ctx) { assert(ctx); - cds_list_del(&ctx->list); + if (ctx->in_list) { + cds_list_del(&ctx->list); + } free(ctx); } diff --git a/src/bin/lttng-sessiond/trace-kernel.h b/src/bin/lttng-sessiond/trace-kernel.h index a39ccd3bb..74bf1df1d 100644 --- a/src/bin/lttng-sessiond/trace-kernel.h +++ b/src/bin/lttng-sessiond/trace-kernel.h @@ -45,6 +45,8 @@ struct ltt_kernel_channel_list { struct ltt_kernel_context { struct lttng_kernel_context ctx; struct cds_list_head list; + /* Indicates whether or not the context is in a list. */ + bool in_list; }; /* Kernel event */