diff --git a/src/userprog/process.c b/src/userprog/process.c index 02adb34..d6bf6c8 100644 --- a/src/userprog/process.c +++ b/src/userprog/process.c @@ -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