Fix: RCU unlock out of error path
authorDavid Goulet <dgoulet@efficios.com>
Thu, 13 Dec 2012 22:51:45 +0000 (17:51 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Thu, 13 Dec 2012 22:54:14 +0000 (17:54 -0500)
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 <dgoulet@efficios.com>
src/bin/lttng-sessiond/channel.c
src/bin/lttng-sessiond/ust-app.c

index d07e1d901fa3ba10170cb259411c105689a6a4a4..ae53c672c6c2a5792ba981324f37097e7f596f6d 100644 (file)
@@ -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,
index 384f8e68812387e8188ad7ef24af80f0b14641e4..6076830099847be986b91be5378d9846c63d63b2 100644 (file)
@@ -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);
This page took 0.028957 seconds and 5 git commands to generate.