diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-13 21:20:48 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-14 07:57:18 -0800 |
commit | e6d83d55698b73b4d5d55d3d7715a4c26030d577 (patch) | |
tree | b2c0e3a799444d9c25c00cf34975b456e0c9ef9d /net | |
parent | c12e87f4652b1ba3be168b4f63a440399b941928 (diff) | |
download | kernel_goldelico_gta04-e6d83d55698b73b4d5d55d3d7715a4c26030d577.zip kernel_goldelico_gta04-e6d83d55698b73b4d5d55d3d7715a4c26030d577.tar.gz kernel_goldelico_gta04-e6d83d55698b73b4d5d55d3d7715a4c26030d577.tar.bz2 |
[PATCH] SUNRPC: Fix potential deadlock in RPC code
In rpc_wake_up() and rpc_wake_up_status(), it is possible for the call to
__rpc_wake_up_task() to fail if another thread happens to be calling
rpc_wake_up_task() on the same rpc_task.
Problem noticed by Bruno Faccini.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/sunrpc/sched.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 802d4fe..e838d04 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -515,16 +515,14 @@ struct rpc_task * rpc_wake_up_next(struct rpc_wait_queue *queue) */ void rpc_wake_up(struct rpc_wait_queue *queue) { - struct rpc_task *task; - + struct rpc_task *task, *next; struct list_head *head; + spin_lock_bh(&queue->lock); head = &queue->tasks[queue->maxpriority]; for (;;) { - while (!list_empty(head)) { - task = list_entry(head->next, struct rpc_task, u.tk_wait.list); + list_for_each_entry_safe(task, next, head, u.tk_wait.list) __rpc_wake_up_task(task); - } if (head == &queue->tasks[0]) break; head--; @@ -541,14 +539,13 @@ void rpc_wake_up(struct rpc_wait_queue *queue) */ void rpc_wake_up_status(struct rpc_wait_queue *queue, int status) { + struct rpc_task *task, *next; struct list_head *head; - struct rpc_task *task; spin_lock_bh(&queue->lock); head = &queue->tasks[queue->maxpriority]; for (;;) { - while (!list_empty(head)) { - task = list_entry(head->next, struct rpc_task, u.tk_wait.list); + list_for_each_entry_safe(task, next, head, u.tk_wait.list) { task->tk_status = status; __rpc_wake_up_task(task); } |