Fix memory leak in start_process due to not freeing proc_start_data when success in initializing stack

This commit is contained in:
Themis Demetriades
2024-11-13 17:21:38 +00:00
parent 8bcd0a467c
commit be68d81cf6

View File

@@ -138,23 +138,25 @@ start_process (void *proc_start_data)
success = load (data->file_name, &if_.eip, &if_.esp);
/* If load failed, quit. */
/* If load failed, free process startup data and quit. */
if (!success)
{
palloc_free_page (data->cmd);
goto fail;
free (data);
thread_exit ();
}
/* Initialize user process stack and free page used to store the
command that executed the process. */
success = process_init_stack (data->cmd_saveptr, &if_.esp, data->file_name);
palloc_free_page (data->cmd);
free (data);
/* If stack initialization failed, free resources and quit. */
/* If stack initialization failed, free process resources and quit. */
if (!success)
{
process_exit ();
goto fail;
thread_exit ();
}
/* Start the user process by simulating a return from an
@@ -165,11 +167,6 @@ start_process (void *proc_start_data)
and jump to it. */
asm volatile ("movl %0, %%esp; jmp intr_exit" : : "g" (&if_) : "memory");
NOT_REACHED ();
/* If starting the process failed, free its common resources and exit. */
fail:
free (data);
thread_exit ();
}
/* Helper function that initializes the stack of a newly created