Commit cda1e453 authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds

[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).
parent 4ccfe3c5
...@@ -150,13 +150,14 @@ static int futex_wait(struct list_head *head, ...@@ -150,13 +150,14 @@ static int futex_wait(struct list_head *head,
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
queue_me(head, &q, page, offset); queue_me(head, &q, page, offset);
/* Page is pinned, can't fail */ /* Page is pinned, but may no longer be in this address space. */
if (get_user(curval, uaddr) != 0) if (get_user(curval, uaddr) != 0) {
BUG(); ret = -EFAULT;
goto out;
}
if (curval != val) { if (curval != val) {
ret = -EWOULDBLOCK; ret = -EWOULDBLOCK;
set_current_state(TASK_RUNNING);
goto out; goto out;
} }
time = schedule_timeout(time); time = schedule_timeout(time);
...@@ -169,6 +170,7 @@ static int futex_wait(struct list_head *head, ...@@ -169,6 +170,7 @@ static int futex_wait(struct list_head *head,
goto out; goto out;
} }
out: out:
set_current_state(TASK_RUNNING);
/* Were we woken up anyway? */ /* Were we woken up anyway? */
if (!unqueue_me(&q)) if (!unqueue_me(&q))
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment