X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fthread.c;h=ff6c0962f33768390500e7e5da2cedee55311a5f;hb=b02f5986773579a5a331d3e108ba52ec9acde2e1;hp=7e16b69ed9ca5ddb113875b87cb6fa7be64c48e0;hpb=b878f05a6e62779ddf2364d5bb51821cb6d6d572;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/thread.c b/src/bin/lttng-sessiond/thread.c index 7e16b69ed..ff6c0962f 100644 --- a/src/bin/lttng-sessiond/thread.c +++ b/src/bin/lttng-sessiond/thread.c @@ -88,7 +88,7 @@ struct lttng_thread *lttng_thread_create(const char *name, thread = zmalloc(sizeof(*thread)); if (!thread) { - goto error; + goto error_alloc; } urcu_ref_init(&thread->ref); @@ -127,9 +127,9 @@ error_pthread_create: /* Release list reference. */ lttng_thread_put(thread); pthread_mutex_unlock(&thread_list.lock); -error: /* Release initial reference. */ lttng_thread_put(thread); +error_alloc: return NULL; } @@ -140,6 +140,9 @@ bool lttng_thread_get(struct lttng_thread *thread) void lttng_thread_put(struct lttng_thread *thread) { + if (!thread) { + return; + } assert(thread->ref.refcount); urcu_ref_put(&thread->ref, lttng_thread_release); } @@ -169,6 +172,7 @@ bool _lttng_thread_shutdown(struct lttng_thread *thread) if (ret) { PERROR("Failed to join \"%s\" thread", thread->name); result = false; + goto end; } /* Release the list's reference to the thread. */ cds_list_del(&thread->node);