SUNRPC: Fix an RCU dereference in xprt_reserve
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 8 Jan 2013 15:03:22 +0000 (10:03 -0500)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 1 Feb 2013 15:13:47 +0000 (10:13 -0500)
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
net/sunrpc/xprt.c

index e1e439ea177f54f8f60c6b4fcd3b63fa65e9cfa5..7f3a01a8cae760cc852226e07909367bc2ce969e 100644 (file)
@@ -1093,7 +1093,7 @@ EXPORT_SYMBOL_GPL(xprt_free);
  */
 void xprt_reserve(struct rpc_task *task)
 {
-       struct rpc_xprt *xprt = task->tk_xprt;
+       struct rpc_xprt *xprt;
 
        task->tk_status = 0;
        if (task->tk_rqstp != NULL)
@@ -1101,7 +1101,10 @@ void xprt_reserve(struct rpc_task *task)
 
        task->tk_timeout = 0;
        task->tk_status = -EAGAIN;
+       rcu_read_lock();
+       xprt = rcu_dereference(task->tk_client->cl_xprt);
        xprt->ops->alloc_slot(xprt, task);
+       rcu_read_unlock();
 }
 
 static inline __be32 xprt_alloc_xid(struct rpc_xprt *xprt)