Changeset 7473807 in mainline for kernel/generic/src/ipc/irq.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/ipc/irq.c

    rae89656 r7473807  
    8282{
    8383        /* Copy the physical base addresses aside. */
    84         uintptr_t *pbase = malloc(rangecount * sizeof(uintptr_t), 0);
     84        uintptr_t *pbase = malloc(rangecount * sizeof(uintptr_t), FRAME_ATOMIC);
     85        if (!pbase)
     86                return ENOMEM;
    8587        for (size_t i = 0; i < rangecount; i++)
    8688                pbase[i] = ranges[i].base;
     
    225227        irq_cmd_t *cmds = NULL;
    226228
    227         irq_code_t *code = malloc(sizeof(*code), 0);
     229        irq_code_t *code = malloc(sizeof(*code), FRAME_ATOMIC);
     230        if (!code)
     231                return NULL;
    228232        errno_t rc = copy_from_uspace(code, ucode, sizeof(*code));
    229233        if (rc != EOK)
     
    234238                goto error;
    235239
    236         ranges = malloc(sizeof(code->ranges[0]) * code->rangecount, 0);
     240        ranges = malloc(sizeof(code->ranges[0]) * code->rangecount,
     241            FRAME_ATOMIC);
     242        if (!ranges)
     243                goto error;
    237244        rc = copy_from_uspace(ranges, code->ranges,
    238245            sizeof(code->ranges[0]) * code->rangecount);
     
    240247                goto error;
    241248
    242         cmds = malloc(sizeof(code->cmds[0]) * code->cmdcount, 0);
     249        cmds = malloc(sizeof(code->cmds[0]) * code->cmdcount, FRAME_ATOMIC);
     250        if (!cmds)
     251                goto error;
    243252        rc = copy_from_uspace(cmds, code->cmds,
    244253            sizeof(code->cmds[0]) * code->cmdcount);
Note: See TracChangeset for help on using the changeset viewer.