Kernel: Make Thread::try_create API OOM safe

This commit is contained in:
Brian Gianforcaro 2021-05-11 03:53:38 -07:00 committed by Andreas Kling
parent d07309a180
commit 112393b38a
Notes: sideshowbarker 2024-07-18 18:15:56 +09:00

View file

@ -41,7 +41,12 @@ KResultOr<NonnullRefPtr<Thread>> Thread::try_create(NonnullRefPtr<Process> proce
if (!kernel_stack_region)
return ENOMEM;
kernel_stack_region->set_stack(true);
return adopt_ref(*new Thread(move(process), kernel_stack_region.release_nonnull()));
auto thread = adopt_ref_if_nonnull(new Thread(move(process), kernel_stack_region.release_nonnull()));
if (!thread)
return ENOMEM;
return thread.release_nonnull();
}
Thread::Thread(NonnullRefPtr<Process> process, NonnullOwnPtr<Region> kernel_stack_region)