util/futex: fix dangling pointer use
authorEric Engestrom <eric.engestrom@intel.com>
Wed, 12 Jun 2019 16:23:27 +0000 (17:23 +0100)
committerEric Engestrom <eric.engestrom@intel.com>
Wed, 12 Jun 2019 16:27:44 +0000 (17:27 +0100)
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110901
Fixes: 7dc2f4788288ec9c7ab6 "util: emulate futex on FreeBSD using umtx"
Cc: Greg V <greg@unrelenting.technology>
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
src/util/futex.h

index a8b2c0f3527df7626958a9e50ea672cf1f016a15..268af92882a1660a691d3c0fbc5cde870bd0b2a1 100644 (file)
@@ -69,15 +69,15 @@ static inline int futex_wake(uint32_t *addr, int count)
 static inline int futex_wait(uint32_t *addr, int32_t value, struct timespec *timeout)
 {
    void *uaddr = NULL, *uaddr2 = NULL;
+   struct _umtx_time tmo = {
+      ._flags = UMTX_ABSTIME,
+      ._clockid = CLOCK_MONOTONIC
+   };
 
    assert(value == (int)(uint32_t)value); /* Check that bits weren't discarded */
 
    if (timeout != NULL) {
-      const struct _umtx_time tmo = {
-         ._timeout = *timeout,
-         ._flags = UMTX_ABSTIME,
-         ._clockid = CLOCK_MONOTONIC
-      };
+      tmo._timeout = *timeout;
       uaddr = (void *)(uintptr_t)sizeof(tmo);
       uaddr2 = (void *)&tmo;
    }