From: Jérémie Galarneau Date: Wed, 29 Aug 2018 21:10:25 +0000 (-0400) Subject: Fix: leak on agent event listing error X-Git-Tag: v2.11.0-rc1~35 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=47e52862a8330d41800736a69de93cec9287cc9d;p=lttng-tools.git Fix: leak on agent event listing error Jumping to the 'error' label after allocating tmp_events results in a memory leak. Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 4ae8a1a35..53a72d9b8 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -490,7 +490,7 @@ static int list_lttng_agent_events(struct agent *agt, int i = 0, ret = 0; unsigned int nb_event = 0; struct agent_event *event; - struct lttng_event *tmp_events; + struct lttng_event *tmp_events = NULL; struct lttng_ht_iter iter; size_t extended_len = 0; void *extended_at; @@ -562,9 +562,12 @@ static int list_lttng_agent_events(struct agent *agt, ret = nb_event; assert(nb_event == i); -error: +end: rcu_read_unlock(); return ret; +error: + free(tmp_events); + goto end; } /*