Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ddi/ddi.c

    r07d4271 r7d83c54  
    5454#include <align.h>
    5555#include <errno.h>
    56 #include <memw.h>
     56#include <mem.h>
    5757#include <trace.h>
    5858#include <bitops.h>
     
    336336                return EPERM;
    337337
     338        irq_spinlock_lock(&tasks_lock, true);
     339
    338340        task_t *task = task_find_by_id(id);
    339341
    340         if (!task)
     342        if ((!task) || (!container_check(CONTAINER, task->container))) {
     343                /*
     344                 * There is no task with the specified ID
     345                 * or the task belongs to a different security
     346                 * context.
     347                 */
     348                irq_spinlock_unlock(&tasks_lock, true);
    341349                return ENOENT;
    342 
    343         errno_t rc = ENOENT;
    344 
    345         irq_spinlock_lock(&task->lock, true);
    346 
    347         /* Check that the task belongs to the correct security context. */
    348         if (container_check(CONTAINER, task->container))
    349                 rc = ddi_iospace_enable_arch(task, ioaddr, size);
    350 
     350        }
     351
     352        /* Lock the task and release the lock protecting tasks dictionary. */
     353        irq_spinlock_exchange(&tasks_lock, &task->lock);
     354        errno_t rc = ddi_iospace_enable_arch(task, ioaddr, size);
    351355        irq_spinlock_unlock(&task->lock, true);
    352         task_release(task);
     356
    353357        return rc;
    354358}
     
    373377                return EPERM;
    374378
     379        irq_spinlock_lock(&tasks_lock, true);
     380
    375381        task_t *task = task_find_by_id(id);
    376382
    377         if (!task)
     383        if ((!task) || (!container_check(CONTAINER, task->container))) {
     384                /*
     385                 * There is no task with the specified ID
     386                 * or the task belongs to a different security
     387                 * context.
     388                 */
     389                irq_spinlock_unlock(&tasks_lock, true);
    378390                return ENOENT;
    379 
    380         errno_t rc = ENOENT;
    381 
    382         irq_spinlock_lock(&task->lock, true);
    383 
    384         /* Check that the task belongs to the correct security context. */
    385         if (container_check(CONTAINER, task->container))
    386                 rc = ddi_iospace_disable_arch(task, ioaddr, size);
    387 
     391        }
     392
     393        /* Lock the task and release the lock protecting tasks dictionary. */
     394        irq_spinlock_exchange(&tasks_lock, &task->lock);
     395        errno_t rc = ddi_iospace_disable_arch(task, ioaddr, size);
    388396        irq_spinlock_unlock(&task->lock, true);
    389         task_release(task);
     397
    390398        return rc;
    391399}
Note: See TracChangeset for help on using the changeset viewer.