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.9.6~2 X-Git-Url: http://git.liburcu.org/?p=lttng-tools.git;a=commitdiff_plain;h=9b09ad37a57826922666af6824210c6cf1f7f81d 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 fb6f96d47..d76166a6e 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -68,6 +68,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 */