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-Tag: v2.6.0-rc4~46 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b01421cf2672b659313e77f26e1b885a3d8c28f4;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 908e5f8fd..d231fb24f 100644 --- a/src/bin/lttng-sessiond/save.c +++ b/src/bin/lttng-sessiond/save.c @@ -1223,6 +1223,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) { @@ -1241,30 +1243,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) {