From 0ab2426242d66243c6d3831ecd2b6f874bf9477d Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Fri, 30 Apr 2021 15:36:06 +0800 Subject: [PATCH] SUNRPC: Test whether the task is queued before grabbing the queue spinlocks 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 Signed-off-by: Huang Guobin Reviewed-by: Yue Haibing Signed-off-by: Yang Yingliang --- net/sunrpc/sched.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index e2808586c9e6..8d204d5a7618 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); -- GitLab