[lttng-dev] [PATCH lttng-tools 02/13] Fix: leak on UST buffer registry creation error
Mathieu Desnoyers
mathieu.desnoyers at efficios.com
Wed Dec 17 20:45:13 EST 2014
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
src/bin/lttng-sessiond/ust-app.c | 21 ++++++++++++++++++---
src/bin/lttng-sessiond/ust-registry.c | 4 +++-
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c
index 891d75f..9dbd49b 100644
--- a/src/bin/lttng-sessiond/ust-app.c
+++ b/src/bin/lttng-sessiond/ust-app.c
@@ -1732,7 +1732,6 @@ static int setup_buffer_reg_pid(struct ust_app_session *ua_sess,
if (ret < 0) {
goto error;
}
- buffer_reg_pid_add(reg_pid);
} else {
goto end;
}
@@ -1745,9 +1744,18 @@ static int setup_buffer_reg_pid(struct ust_app_session *ua_sess,
app->byte_order, app->version.major,
app->version.minor);
if (ret < 0) {
+ /*
+ * reg_pid->registry->reg.ust is NULL upon error, so we need to
+ * destroy the buffer registry, because it is always expected
+ * that if the buffer registry can be found, its ust registry is
+ * non-NULL.
+ */
+ buffer_reg_pid_destroy(reg_pid);
goto error;
}
+ buffer_reg_pid_add(reg_pid);
+
DBG3("UST app buffer registry per PID created successfully");
end:
@@ -1788,7 +1796,6 @@ static int setup_buffer_reg_uid(struct ltt_ust_session *usess,
if (ret < 0) {
goto error;
}
- buffer_reg_uid_add(reg_uid);
} else {
goto end;
}
@@ -1801,13 +1808,21 @@ static int setup_buffer_reg_uid(struct ltt_ust_session *usess,
app->byte_order, app->version.major,
app->version.minor);
if (ret < 0) {
+ /*
+ * reg_uid->registry->reg.ust is NULL upon error, so we need to
+ * destroy the buffer registry, because it is always expected
+ * that if the buffer registry can be found, its ust registry is
+ * non-NULL.
+ */
+ buffer_reg_uid_destroy(reg_uid, NULL);
goto error;
}
/* Add node to teardown list of the session. */
cds_list_add(®_uid->lnode, &usess->buffer_reg_uid_list);
- DBG3("UST app buffer registry per UID created successfully");
+ buffer_reg_uid_add(reg_uid);
+ DBG3("UST app buffer registry per UID created successfully");
end:
if (regp) {
*regp = reg_uid;
diff --git a/src/bin/lttng-sessiond/ust-registry.c b/src/bin/lttng-sessiond/ust-registry.c
index 3f4a962..1a00e93 100644
--- a/src/bin/lttng-sessiond/ust-registry.c
+++ b/src/bin/lttng-sessiond/ust-registry.c
@@ -608,7 +608,9 @@ void ust_registry_session_destroy(struct ust_registry_session *reg)
struct lttng_ht_iter iter;
struct ust_registry_channel *chan;
- assert(reg);
+ if (!reg) {
+ return;
+ }
/* On error, EBUSY can be returned if lock. Code flow error. */
ret = pthread_mutex_destroy(®->lock);
--
2.1.1
More information about the lttng-dev
mailing list