From: Mathieu Desnoyers Date: Mon, 19 Mar 2012 22:02:45 +0000 (-0400) Subject: Fix: various memleaks X-Git-Tag: v2.0.0-rc4~17 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=a2c0da862b4c3286fa919b96556bc30e8914e28b;p=lttng-tools.git Fix: various memleaks Thanks to valgrind. Acked-by: David Goulet Signed-off-by: Mathieu Desnoyers --- diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 8b09fc922..0c4d4b1f9 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -3798,7 +3798,7 @@ static void *thread_manage_clients(void *data) PERROR("close"); } sock = -1; - free(cmd_ctx); + clean_command_ctx(&cmd_ctx); continue; } diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index 48f6eea7d..293ca381b 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -228,6 +228,8 @@ struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev) return lke; error: + free(lke); + free(attr); return NULL; } @@ -270,6 +272,8 @@ struct ltt_kernel_metadata *trace_kernel_create_metadata(char *path) return lkm; error: + free(lkm); + free(chan); return NULL; } diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 8cc1b5915..5a8fc7dd9 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -121,6 +121,9 @@ struct ltt_ust_session *trace_ust_create_session(char *path, int session_id, return lus; error_free_session: + lttng_ht_destroy(lus->domain_global.channels); + lttng_ht_destroy(lus->domain_exec); + lttng_ht_destroy(lus->domain_pid); free(lus); error: return NULL; @@ -180,6 +183,8 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, return luc; error_free_channel: + lttng_ht_destroy(luc->ctx); + lttng_ht_destroy(luc->events); free(luc); error: return NULL; @@ -253,6 +258,7 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev) return lue; error_free_event: + lttng_ht_destroy(lue->ctx); free(lue); error: return NULL; diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 10ffe403b..79526fceb 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -150,6 +150,7 @@ void delete_ust_app_session(int sock, struct ust_app_session *ua_sess) ustctl_release_object(sock, ua_sess->metadata->obj); free(ua_sess->metadata->obj); } + trace_ust_destroy_metadata(ua_sess->metadata); } cds_lfht_for_each_entry(ua_sess->channels->ht, &iter.iter, ua_chan, @@ -1980,6 +1981,7 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) &ustream->obj); if (ret < 0) { /* Got all streams */ + free(ustream); break; } ustream->handle = ustream->obj->handle; @@ -1991,6 +1993,10 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) ua_chan->streams.count++); if (ret < 0) { PERROR("asprintf UST create stream"); + /* + * XXX what should we do here with the + * stream ? + */ continue; } DBG2("UST stream %d ready at %s", ua_chan->streams.count,