Changeset 7473807 in mainline for kernel/generic/src/synch/futex.c


Ignore:
Timestamp:
2018-05-11T20:22:42Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d2c5159
Parents:
ae89656
Message:

Use atomic malloc allocations

We can safely use atomic allocations in places that use the non-failing
version of malloc(), but test the return value anyway. And also in some
places that can afford to return failure but did not because of comfort.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/synch/futex.c

    rae89656 r7473807  
    339339static futex_t *get_and_cache_futex(uintptr_t phys_addr, uintptr_t uaddr)
    340340{
    341         futex_t *futex = malloc(sizeof(futex_t), 0);
     341        futex_t *futex = malloc(sizeof(futex_t), FRAME_ATOMIC);
     342        if (!futex)
     343                return NULL;
    342344
    343345        /*
     
    363365         * Cache the link to the futex object for this task.
    364366         */
    365         futex_ptr_t *fut_ptr = malloc(sizeof(futex_ptr_t), 0);
     367        futex_ptr_t *fut_ptr = malloc(sizeof(futex_ptr_t), FRAME_ATOMIC);
     368        if (!fut_ptr) {
     369                spinlock_lock(&futex_ht_lock);
     370                futex_release_ref(futex);
     371                spinlock_unlock(&futex_ht_lock);
     372                return NULL;
     373        }
    366374        cht_link_t *dup_link;
    367375
Note: See TracChangeset for help on using the changeset viewer.