kernel: resolving a handle now increments the refcount of the corresponding object

This commit is contained in:
2026-03-12 20:42:05 +00:00
parent 5a37b5e148
commit 6ba236b2fe
5 changed files with 7 additions and 39 deletions

View File

@@ -84,7 +84,6 @@ kern_status_t sys_task_create(
return status;
}
object_ref(parent_obj);
struct task *parent = task_cast(parent_obj);
struct handle *child_handle_slot = NULL, *space_handle_slot = NULL;
@@ -94,6 +93,7 @@ kern_status_t sys_task_create(
&child_handle_slot,
&child_handle);
if (status != KERN_OK) {
object_unref(parent_obj);
task_unlock_irqrestore(self, flags);
return status;
}
@@ -103,6 +103,7 @@ kern_status_t sys_task_create(
&space_handle_slot,
&space_handle);
if (status != KERN_OK) {
object_unref(parent_obj);
handle_table_free_handle(self->t_handles, child_handle);
task_unlock_irqrestore(self, flags);
return status;
@@ -169,7 +170,6 @@ kern_status_t sys_task_create_thread(
return status;
}
object_ref(target_obj);
struct task *target = task_cast(target_obj);
struct handle *target_handle = NULL;
@@ -238,6 +238,7 @@ kern_status_t sys_task_get_address_space(
&handle_slot,
&handle);
if (status != KERN_OK) {
object_unref(task_obj);
task_unlock_irqrestore(self, flags);
return status;
}
@@ -245,6 +246,7 @@ kern_status_t sys_task_get_address_space(
struct task *task = task_cast(task_obj);
if (!task) {
object_unref(task_obj);
handle_table_free_handle(self->t_handles, handle);
task_unlock_irqrestore(self, flags);
return KERN_INVALID_ARGUMENT;
@@ -253,6 +255,7 @@ kern_status_t sys_task_get_address_space(
handle_slot->h_object = &task->t_address_space->vr_base;
object_add_handle(&task->t_address_space->vr_base);
task_unlock_irqrestore(self, flags);
object_unref(task_obj);
*out = handle;
return KERN_OK;
@@ -276,11 +279,11 @@ kern_status_t sys_thread_start(kern_handle_t thread_handle)
return status;
}
object_ref(thread_obj);
struct thread *thread = thread_cast(thread_obj);
task_unlock_irqrestore(self, flags);
schedule_thread_on_cpu(thread);
object_unref(thread_obj);
return KERN_OK;
}