From: Mathieu Desnoyers Date: Fri, 25 Nov 2011 10:51:52 +0000 (+0100) Subject: channel_new_default_attr: fix usage memory leaks X-Git-Tag: v2.0-pre15~73 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ff4d74e67c570a1419df7315453a60e9d1f16a7d;p=lttng-tools.git channel_new_default_attr: fix usage memory leaks Signed-off-by: Mathieu Desnoyers --- diff --git a/lttng-sessiond/channel.c b/lttng-sessiond/channel.c index 2dd9840d4..9fd98b82d 100644 --- a/lttng-sessiond/channel.c +++ b/lttng-sessiond/channel.c @@ -161,19 +161,19 @@ error: * Create kernel channel of the kernel session and notify kernel thread. */ int channel_kernel_create(struct ltt_kernel_session *ksession, - struct lttng_channel *chan, int kernel_pipe) + struct lttng_channel *attr, int kernel_pipe) { int ret; - struct lttng_channel *attr = chan; + struct lttng_channel *defattr = NULL; /* Creating channel attributes if needed */ if (attr == NULL) { - /* FIXME: this appears to be a memory leak */ - attr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL); - if (attr == NULL) { + defattr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL); + if (defattr == NULL) { ret = LTTCOMM_FATAL; goto error; } + attr = defattr; } /* Channel not found, creating it */ @@ -191,8 +191,8 @@ int channel_kernel_create(struct ltt_kernel_session *ksession, } ret = LTTCOMM_OK; - error: + free(defattr); return ret; } diff --git a/lttng-sessiond/main.c b/lttng-sessiond/main.c index ae994d7e5..9af001dfd 100644 --- a/lttng-sessiond/main.c +++ b/lttng-sessiond/main.c @@ -2474,8 +2474,10 @@ static int cmd_enable_event(struct ltt_session *session, int domain, ret = channel_kernel_create(session->kernel_session, attr, kernel_poll_pipe[1]); if (ret != LTTCOMM_OK) { + free(attr); goto error; } + free(attr); } /* Get the newly created kernel channel pointer */ @@ -2516,6 +2518,7 @@ static int cmd_enable_event(struct ltt_session *session, int domain, /* Use the internal command enable channel */ ret = cmd_enable_channel(session, domain, attr); if (ret < 0) { + free(attr); goto error; }