From 309058888c6fc4ce3dae0c07806673c9170859bd Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 8 Oct 2022 13:12:19 +0000 Subject: [PATCH] Bugfix: remove duplicate error check when loading a userspace ELF program Also, remember to delete the allocated task, since we do not want memory leaks :) --- kernel/src/thread/Scheduler.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/kernel/src/thread/Scheduler.cpp b/kernel/src/thread/Scheduler.cpp index 87537372..9978cefc 100644 --- a/kernel/src/thread/Scheduler.cpp +++ b/kernel/src/thread/Scheduler.cpp @@ -121,16 +121,11 @@ void Scheduler::load_user_task(const char* filename) if (!image) { kerrorln("Failed to load %s from initrd", filename); + delete new_task; return; } new_task->regs.rip = image->entry; new_task->image = image; - if (!new_task->regs.rip) - { - kwarnln("Failed to load user task %s", filename); - delete new_task; - return; - } new_task->allocated_stack = (uint64_t)MemoryManager::get_pages( TASK_PAGES_IN_STACK, MAP_READ_WRITE | MAP_USER); // 16 KB is enough for everyone, right? new_task->regs.rsp = new_task->allocated_stack + (PAGE_SIZE * TASK_PAGES_IN_STACK) - sizeof(uintptr_t);