]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-bus: initialize mutex after we allocated the wqueue
authorLennart Poettering <lennart@poettering.net>
Thu, 17 Jan 2019 20:06:30 +0000 (21:06 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 1 Mar 2019 14:19:45 +0000 (15:19 +0100)
That way the mutex doesn't have to be destroyed when we exit early due
to OOM.

src/libsystemd/sd-bus/sd-bus.c

index 9eeb3c448c2f22de69cdac3b040df2c184bbfcbe..0df3366d806e7af18fff0b460ad357c3d74da7d7 100644 (file)
@@ -248,12 +248,12 @@ _public_ int sd_bus_new(sd_bus **ret) {
                 .close_on_exit = true,
         };
 
-        assert_se(pthread_mutex_init(&b->memfd_cache_mutex, NULL) == 0);
-
         /* We guarantee that wqueue always has space for at least one entry */
         if (!GREEDY_REALLOC(b->wqueue, b->wqueue_allocated, 1))
                 return -ENOMEM;
 
+        assert_se(pthread_mutex_init(&b->memfd_cache_mutex, NULL) == 0);
+
         *ret = TAKE_PTR(b);
         return 0;
 }