From: David Goulet Date: Thu, 13 Dec 2012 22:51:45 +0000 (-0500) Subject: Fix: RCU unlock out of error path X-Git-Tag: v2.1.0~52 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=95e047ff8e01767e2e18b892f7a1ba9bf28abcbe;p=lttng-tools.git Fix: RCU unlock out of error path On channel error, RCU was not unlocking the read side. Furthermore, remove a check for a NULL session that was also not going through an RCU unlock. Change it to an assert. This also adds a channel subbuf size check when enabling a channel. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c index d07e1d901..ae53c672c 100644 --- a/src/bin/lttng-sessiond/channel.c +++ b/src/bin/lttng-sessiond/channel.c @@ -240,6 +240,11 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain, attr = defattr; } + if (attr->attr.subbuf_size < DEFAULT_UST_CHANNEL_SUBBUF_SIZE) { + ret = LTTNG_ERR_INVALID; + goto error; + } + /* * Validate UST buffer size and number of buffers: must both be * power of 2 and nonzero. We validate right here for UST, diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 384f8e688..607683009 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -2050,7 +2050,7 @@ int ust_app_create_channel_glb(struct ltt_ust_session *usess, if (ua_sess == NULL) { /* The malloc() failed. */ ret = -1; - goto error; + goto error_rcu_unlock; } else if (ua_sess == (void *) -1UL) { /* The application's socket is not valid. Contiuing */ ret = -1; @@ -2062,13 +2062,12 @@ int ust_app_create_channel_glb(struct ltt_ust_session *usess, if (ua_chan == NULL) { /* Major problem here and it's maybe the tracer or malloc() */ ret = -1; - goto error; + goto error_rcu_unlock; } } +error_rcu_unlock: rcu_read_unlock(); - -error: return ret; } @@ -2581,10 +2580,7 @@ void ust_app_global_update(struct ltt_ust_session *usess, int sock) struct ust_app_event *ua_event; struct ust_app_ctx *ua_ctx; - if (usess == NULL) { - ERR("No UST session on global update. Returning"); - goto error; - } + assert(usess); DBG2("UST app global update for app sock %d for session id %d", sock, usess->id);