Fix memory leak in start_process due to not freeing proc_start_data when success in initializing stack
This commit is contained in:
@@ -138,23 +138,25 @@ start_process (void *proc_start_data)
|
|||||||
|
|
||||||
success = load (data->file_name, &if_.eip, &if_.esp);
|
success = load (data->file_name, &if_.eip, &if_.esp);
|
||||||
|
|
||||||
/* If load failed, quit. */
|
/* If load failed, free process startup data and quit. */
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
palloc_free_page (data->cmd);
|
palloc_free_page (data->cmd);
|
||||||
goto fail;
|
free (data);
|
||||||
|
thread_exit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize user process stack and free page used to store the
|
/* Initialize user process stack and free page used to store the
|
||||||
command that executed the process. */
|
command that executed the process. */
|
||||||
success = process_init_stack (data->cmd_saveptr, &if_.esp, data->file_name);
|
success = process_init_stack (data->cmd_saveptr, &if_.esp, data->file_name);
|
||||||
palloc_free_page (data->cmd);
|
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)
|
if (!success)
|
||||||
{
|
{
|
||||||
process_exit ();
|
process_exit ();
|
||||||
goto fail;
|
thread_exit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start the user process by simulating a return from an
|
/* Start the user process by simulating a return from an
|
||||||
@@ -165,11 +167,6 @@ start_process (void *proc_start_data)
|
|||||||
and jump to it. */
|
and jump to it. */
|
||||||
asm volatile ("movl %0, %%esp; jmp intr_exit" : : "g" (&if_) : "memory");
|
asm volatile ("movl %0, %%esp; jmp intr_exit" : : "g" (&if_) : "memory");
|
||||||
NOT_REACHED ();
|
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
|
/* Helper function that initializes the stack of a newly created
|
||||||
|
|||||||
Reference in New Issue
Block a user