]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/sync_sema.c
xnu-7195.101.1.tar.gz
[apple/xnu.git] / osfmk / kern / sync_sema.c
index 31ea5caaedf96c1f00ddd6dedb110fb2cbcab0f3..dfa8d1153ae4a89e0e4910f0df7ff31b387deb03 100644 (file)
@@ -180,6 +180,12 @@ semaphore_create(
         *  the new semaphore to the task's semaphore list.
         */
        task_lock(task);
+       /* Check for race with task_terminate */
+       if (!task->active) {
+               task_unlock(task);
+               zfree(semaphore_zone, s);
+               return KERN_INVALID_TASK;
+       }
        enqueue_head(&task->semaphore_list, (queue_entry_t) s);
        task->semaphores_owned++;
        task_unlock(task);