From 5b951542a175819b62269e6904641f1a26149c96 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 14 Nov 2018 17:49:21 -0500 Subject: [PATCH] Fix: create_channel_per_pid: remove channel on error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The notification system of the session daemon tracks the lifetime of per-pid buffers (in effect, channel keys) using two hooks: - the successful completion of create_channel_per_pid() - the deletion of the channel from an application's registry Multiple error paths in create_channel_per_pid() can leave a channel in an app's registry without notifying the notification system of its existence. When the channel is finally cleaned-up, the channel deletion hook will inform the notification system that the channel should be deleted, resulting in an error as that channel was previously unknown. This fix ensures we remove the application's channel from its registry on error (with the notify parameter set to 'false'), thus ensuring that the notification system never tracks the incomplete channel. Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/ust-app.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index f97d869e6..2c1b845ad 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -3019,7 +3019,7 @@ static int create_channel_per_pid(struct ust_app *app, if (ret < 0) { ERR("Error creating UST channel \"%s\" on the consumer daemon", ua_chan->name); - goto error; + goto error_remove_from_registry; } ret = send_channel_pid_to_ust(app, ua_sess, ua_chan); @@ -3027,7 +3027,7 @@ static int create_channel_per_pid(struct ust_app *app, if (ret != -ENOTCONN) { ERR("Error sending channel to application"); } - goto error; + goto error_remove_from_registry; } chan_reg_key = ua_chan->key; @@ -3047,9 +3047,13 @@ static int create_channel_per_pid(struct ust_app *app, if (cmd_ret != LTTNG_OK) { ret = - (int) cmd_ret; ERR("Failed to add channel to notification thread"); - goto error; + goto error_remove_from_registry; } +error_remove_from_registry: + if (ret) { + ust_registry_channel_del_free(registry, ua_chan->key, false); + } error: rcu_read_unlock(); return ret; -- 2.34.1