Fix: possible use after free
authorDavid Goulet <dgoulet@efficios.com>
Thu, 5 Dec 2013 22:05:40 +0000 (17:05 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Thu, 5 Dec 2013 22:09:07 +0000 (17:09 -0500)
Fixes coverity issue 1135328 and 1135329

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/ust-app.c

index c7bcc85f5e0b8fed7ef9aeff108f3fb630517e95..d1fa0d09cb2b04d75b3419cd6fa969a602253eb0 100644 (file)
@@ -3125,7 +3125,6 @@ int ust_app_list_events(struct lttng_event **events)
                                        &uiter)) != -LTTNG_UST_ERR_NOENT) {
                        /* Handle ustctl error. */
                        if (ret < 0) {
-                               free(tmp_event);
                                if (ret != -LTTNG_UST_ERR_EXITING && ret != -EPIPE) {
                                        ERR("UST app tp list get failed for app %d with ret %d",
                                                        app->sock, ret);
@@ -3138,6 +3137,7 @@ int ust_app_list_events(struct lttng_event **events)
                                         */
                                        break;
                                }
+                               free(tmp_event);
                                goto rcu_error;
                        }
 
@@ -3225,7 +3225,6 @@ int ust_app_list_event_fields(struct lttng_event_field **fields)
                                        &uiter)) != -LTTNG_UST_ERR_NOENT) {
                        /* Handle ustctl error. */
                        if (ret < 0) {
-                               free(tmp_event);
                                if (ret != -LTTNG_UST_ERR_EXITING && ret != -EPIPE) {
                                        ERR("UST app tp list field failed for app %d with ret %d",
                                                        app->sock, ret);
@@ -3234,10 +3233,11 @@ int ust_app_list_event_fields(struct lttng_event_field **fields)
                                        /*
                                         * This is normal behavior, an application can die during the
                                         * creation process. Don't report an error so the execution can
-                                        * continue normally.
+                                        * continue normally. Reset list and count for next app.
                                         */
                                        break;
                                }
+                               free(tmp_event);
                                goto rcu_error;
                        }
 
This page took 0.028373 seconds and 4 git commands to generate.