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.10.1~3 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2b64f14cda0b07b4aed432539749508c132da04e;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 2031bfb38..2cbed3818 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 54bdc6675..52b8cc7e0 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -501,7 +501,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 0ac020f97..2eb599272 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 */