From: David Goulet Date: Mon, 14 Jan 2013 20:36:17 +0000 (-0500) Subject: Destroy created kernel channel on enable all error X-Git-Tag: v2.2.0-rc1~115 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e5f5db7fe1ce6cf8e0ac6b2be2b4c85c2ba68375;p=lttng-tools.git Destroy created kernel channel on enable all error If we had to create a channel for an enable all tracepoint call (-a -k) and the enable fails, destroy the created kernel channel. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 491acde45..ff418e17e 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -1111,7 +1111,7 @@ int cmd_enable_event(struct ltt_session *session, int domain, char *channel_name, struct lttng_event *event, struct lttng_filter_bytecode *filter, int wpipe) { - int ret; + int ret, channel_created = 0; struct lttng_channel *attr; assert(session); @@ -1139,6 +1139,8 @@ int cmd_enable_event(struct ltt_session *session, int domain, goto error; } free(attr); + + channel_created = 1; } /* Get the newly created kernel channel pointer */ @@ -1153,6 +1155,10 @@ int cmd_enable_event(struct ltt_session *session, int domain, ret = event_kernel_enable_tracepoint(session->kernel_session, kchan, event); if (ret != LTTNG_OK) { + if (channel_created) { + /* Let's not leak a useless channel. */ + kernel_destroy_channel(kchan); + } goto error; } @@ -1283,6 +1289,10 @@ int cmd_enable_event_all(struct ltt_session *session, int domain, /* Manage return value */ if (ret != LTTNG_OK) { + /* + * On error, cmd_enable_channel call will take care of destroying + * the created channel if it was needed. + */ goto error; }