diff options
| -rw-r--r-- | userprog/syscall.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/userprog/syscall.c b/userprog/syscall.c index 71aba5c..7f8c397 100644 --- a/userprog/syscall.c +++ b/userprog/syscall.c | |||
| @@ -201,10 +201,10 @@ syscall_handler (struct intr_frame *f) | |||
| 201 | handler* fp; | 201 | handler* fp; |
| 202 | bool segfault = false; | 202 | bool segfault = false; |
| 203 | int result; | 203 | int result; |
| 204 | syscall_sp = f->esp; | 204 | void *sp = f->esp; |
| 205 | 205 | ||
| 206 | /* The system call number and the arguments are on the stack */ | 206 | /* The system call number and the arguments are on the stack */ |
| 207 | if (! copy_from_user (&syscall_nr,syscall_sp)) | 207 | if (! copy_from_user (&syscall_nr,sp)) |
| 208 | goto fail; | 208 | goto fail; |
| 209 | switch (syscall_nr) { | 209 | switch (syscall_nr) { |
| 210 | case SYS_HALT: fp = syscall_halt; break; | 210 | case SYS_HALT: fp = syscall_halt; break; |
| @@ -225,8 +225,9 @@ syscall_handler (struct intr_frame *f) | |||
| 225 | default: | 225 | default: |
| 226 | goto fail; | 226 | goto fail; |
| 227 | } | 227 | } |
| 228 | result = fp (syscall_sp, &segfault); | 228 | syscall_sp = sp; |
| 229 | if (segfault) | 229 | result = fp (sp, &segfault); |
| 230 | if (segfault) | ||
| 230 | goto fail; | 231 | goto fail; |
| 231 | f->eax = result; | 232 | f->eax = result; |
| 232 | return; | 233 | return; |
