From: Trond Myklebust trond.myklebust@hammerspace.com
mainline inclusion from mainline-4.20-rc1 commit 5ce970393bad41499d50dfaea525ac8f01cdbc30 category: bugfix bugzilla: 51820 CVE: NA
-------------------------------------------------
When asked to wake up an RPC task, it makes sense to test whether or not the task is still queued.
Signed-off-by: Trond Myklebust trond.myklebust@hammerspace.com Signed-off-by: Huang Guobin huangguobin4@huawei.com Reviewed-by: Yue Haibing yuehaibing@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- net/sunrpc/sched.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index e2808586c9e61..8d204d5a76187 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -474,6 +474,8 @@ void rpc_wake_up_queued_task_on_wq(struct workqueue_struct *wq, struct rpc_wait_queue *queue, struct rpc_task *task) { + if (!RPC_IS_QUEUED(task)) + return; spin_lock_bh(&queue->lock); rpc_wake_up_task_on_wq_queue_locked(wq, queue, task); spin_unlock_bh(&queue->lock); @@ -484,6 +486,8 @@ void rpc_wake_up_queued_task_on_wq(struct workqueue_struct *wq, */ void rpc_wake_up_queued_task(struct rpc_wait_queue *queue, struct rpc_task *task) { + if (!RPC_IS_QUEUED(task)) + return; spin_lock_bh(&queue->lock); rpc_wake_up_task_queue_locked(queue, task); spin_unlock_bh(&queue->lock);