From fc7324e801c73fed022757ea47b0b245a5a527f7 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Mon, 22 Sep 2014 11:03:24 -0400 Subject: [PATCH] Fix: kernel context memory leak on error Fixes Coverity issue 1223776. Signed-off-by: David Goulet --- src/bin/lttng-sessiond/context.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng-sessiond/context.c b/src/bin/lttng-sessiond/context.c index 10352d026..2cc6a30a8 100644 --- a/src/bin/lttng-sessiond/context.c +++ b/src/bin/lttng-sessiond/context.c @@ -198,7 +198,8 @@ int context_kernel_add(struct ltt_kernel_session *ksession, kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_PERF_CPU_COUNTER; break; default: - return LTTNG_ERR_KERN_CONTEXT_FAIL; + ret = LTTNG_ERR_KERN_CONTEXT_FAIL; + goto error; } kctx->ctx.u.perf_counter.type = ctx->u.perf_counter.type; @@ -226,9 +227,12 @@ int context_kernel_add(struct ltt_kernel_session *ksession, } } - ret = LTTNG_OK; + return LTTNG_OK; error: + if (kctx) { + trace_kernel_destroy_context(kctx); + } return ret; } -- 2.34.1