summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-01-17 21:06:30 +0100
committerLukas Nykryn <lnykryn@redhat.com>2020-02-03 11:05:28 +0100
commitfb04f17617458d2d3d09e0bef29f1255d4d3500c (patch)
treeab1967cb83eb2ac0df9c4e81ea48ca0857e3b7aa
parente81231e9a88ebc68c715010ce288c1d59c52e88f (diff)
downloadsystemd-fb04f17617458d2d3d09e0bef29f1255d4d3500c.tar.gz
sd-bus: initialize mutex after we allocated the wqueue
That way the mutex doesn't have to be destroyed when we exit early due to OOM. (cherry picked from commit 2fe9a10d7695c4c3a748969a0d1662c624e50e5e) Related: CVE-2020-1712
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 01060d105c..e49d58137d 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -248,12 +248,12 @@ _public_ int sd_bus_new(sd_bus **ret) {
b->original_pid = getpid_cached();
b->n_groups = (size_t) -1;
- 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;
}