From: Jérémie Galarneau Date: Tue, 18 Nov 2014 19:09:36 +0000 (-0500) Subject: Fix: Missing rcu_read_lock in save_domains() X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=65d72c41ed358620e40a7f6afb07e785e31c0d6a;p=lttng-tools.git Fix: Missing rcu_read_lock in save_domains() Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/save.c b/src/bin/lttng-sessiond/save.c index b78e7f785..c6fc33e7b 100644 --- a/src/bin/lttng-sessiond/save.c +++ b/src/bin/lttng-sessiond/save.c @@ -1225,6 +1225,8 @@ int save_domains(struct config_writer *writer, struct ltt_session *session) } if (session->ust_session) { + unsigned long agent_count; + ret = config_writer_open_element(writer, config_element_domain); if (ret) { @@ -1243,30 +1245,37 @@ int save_domains(struct config_writer *writer, struct ltt_session *session) ret = LTTNG_ERR_SAVE_IO_FAIL; goto end; } - } - if (session->ust_session && - lttng_ht_get_count(session->ust_session->agents) > 0) { - ret = config_writer_open_element(writer, - config_element_domain); - if (ret) { - ret = LTTNG_ERR_SAVE_IO_FAIL; - goto end; - } + rcu_read_lock(); + agent_count = + lttng_ht_get_count(session->ust_session->agents); + rcu_read_unlock(); - ret = save_ust_session(writer, session, 1); - if (ret) { - goto end; - } + if (agent_count > 0) { + ret = config_writer_open_element(writer, + config_element_domain); + if (ret) { + ret = LTTNG_ERR_SAVE_IO_FAIL; + goto end; + } - /* /domain */ - ret = config_writer_close_element(writer); - if (ret) { - ret = LTTNG_ERR_SAVE_IO_FAIL; - goto end; + ret = save_ust_session(writer, session, 1); + if (ret) { + goto end; + } + + /* /domain */ + ret = config_writer_close_element(writer); + if (ret) { + ret = LTTNG_ERR_SAVE_IO_FAIL; + goto end; + } } } + if (session->ust_session) { + } + /* /domains */ ret = config_writer_close_element(writer); if (ret) {