From: Jonathan Rajotte Date: Tue, 11 Sep 2018 00:09:11 +0000 (-0400) Subject: Fix: double put on error path X-Git-Tag: v2.10.6~19 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=a86c0657eb37be08e07549a2444c5dc05b0dbda6;p=lttng-tools.git Fix: double put on error path Let relay_index_try_flush be responsible for the self-reference put on error path. Code flow of relay_index_try_flush is a bit tricky but the only error flow (via relay_index_file_write) will always mark the index as flushed and perform the self-reference put. Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 0253997f7..6f439176f 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -2054,8 +2054,13 @@ static int relay_recv_index(struct lttcomm_relayd_hdr *recv_hdr, /* no flush. */ ret = 0; } else { + /* + * ret < 0 + * + * relay_index_try_flush is responsible for the self-reference + * put of the index object on error. + */ ERR("relay_index_try_flush error %d", ret); - relay_index_put(index); ret = -1; } @@ -2255,9 +2260,13 @@ static int handle_index_data(struct relay_stream *stream, uint64_t net_seq_num, /* No flush. */ ret = 0; } else { - /* Put self-ref for this index due to error. */ - relay_index_put(index); - index = NULL; + /* + * ret < 0 + * + * relay_index_try_flush is responsible for the self-reference + * put of the index object on error. + */ + ERR("relay_index_try_flush error %d", ret); ret = -1; } end: