diff options
| author | Rusty Russell <rusty@rustcorp.com.au> | 2002-06-05 19:25:39 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2002-06-05 19:25:39 -0700 |
| commit | cda1e453414bc017729c65dfc8f5a61e86676c4e (patch) | |
| tree | 119f1cc5ae5f655eff2f02981e03816a14b727c5 | |
| parent | 4ccfe3c58319acb4f865bbef435013ef3af5ee1f (diff) | |
[PATCH] Futex II: Copy-from-user can fail.
This patch handles the case where copy_from_user fails (it could
have been unmapped from this address space by another thread).
| -rw-r--r-- | kernel/futex.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/kernel/futex.c b/kernel/futex.c index ed03e2b73787..029c902869f4 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -150,13 +150,14 @@ static int futex_wait(struct list_head *head, set_current_state(TASK_INTERRUPTIBLE); queue_me(head, &q, page, offset); - /* Page is pinned, can't fail */ - if (get_user(curval, uaddr) != 0) - BUG(); + /* Page is pinned, but may no longer be in this address space. */ + if (get_user(curval, uaddr) != 0) { + ret = -EFAULT; + goto out; + } if (curval != val) { ret = -EWOULDBLOCK; - set_current_state(TASK_RUNNING); goto out; } time = schedule_timeout(time); @@ -169,6 +170,7 @@ static int futex_wait(struct list_head *head, goto out; } out: + set_current_state(TASK_RUNNING); /* Were we woken up anyway? */ if (!unqueue_me(&q)) return 0; |
