Fix: kernel context memory leak on error
authorDavid Goulet <dgoulet@efficios.com>
Mon, 22 Sep 2014 15:03:24 +0000 (11:03 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 22 Sep 2014 15:03:24 +0000 (11:03 -0400)
Fixes Coverity issue 1223776.

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/context.c

index 10352d026952ec3361acccf6aa07ac97bab4b34f..2cc6a30a84fd5d0e93566261c3c462d1f61bba55 100644 (file)
@@ -198,7 +198,8 @@ int context_kernel_add(struct ltt_kernel_session *ksession,
                kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_PERF_CPU_COUNTER;
                break;
        default:
                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;
        }
 
        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:
 
 error:
+       if (kctx) {
+               trace_kernel_destroy_context(kctx);
+       }
        return ret;
 }
 
        return ret;
 }
 
This page took 0.026051 seconds and 4 git commands to generate.