sched: enforce ref-counting on current task/thread pointers
This commit is contained in:
+11
-3
@@ -13,12 +13,13 @@ kern_status_t sys_kern_object_wait(kern_wait_item_t *items, size_t nr_items)
|
||||
return KERN_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
struct task *self = current_task();
|
||||
struct thread *self_thread = current_thread();
|
||||
struct task *self = get_current_task();
|
||||
if (!validate_access_rw(self, items, nr_items * sizeof *items)) {
|
||||
put_current_task(self);
|
||||
return KERN_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
struct thread *self_thread = get_current_thread();
|
||||
self_thread->tr_state = THREAD_SLEEPING;
|
||||
|
||||
kern_status_t status = KERN_OK;
|
||||
@@ -78,6 +79,9 @@ cleanup:
|
||||
}
|
||||
|
||||
self_thread->tr_state = THREAD_READY;
|
||||
put_current_thread(self_thread);
|
||||
put_current_task(self);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -85,13 +89,15 @@ kern_status_t sys_kern_object_query(
|
||||
kern_handle_t object_handle,
|
||||
kern_object_info_t *out)
|
||||
{
|
||||
struct task *self = current_task();
|
||||
struct task *self = get_current_task();
|
||||
|
||||
if (!out) {
|
||||
put_current_task(self);
|
||||
return KERN_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (!validate_access_w(self, out, sizeof *out)) {
|
||||
put_current_task(self);
|
||||
return KERN_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
@@ -100,12 +106,14 @@ kern_status_t sys_kern_object_query(
|
||||
kern_status_t status
|
||||
= task_resolve_handle(self, object_handle, &obj, &flags);
|
||||
if (status != KERN_OK) {
|
||||
put_current_task(self);
|
||||
return status;
|
||||
}
|
||||
|
||||
out->obj_id = obj->ob_id;
|
||||
|
||||
object_unref(obj);
|
||||
put_current_task(self);
|
||||
|
||||
return KERN_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user