NFSv4: Fix an rcu lock leak
authorTrond Myklebust <trond.myklebust@primarydata.com>
Fri, 5 May 2017 17:02:42 +0000 (13:02 -0400)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Mon, 8 May 2017 13:27:59 +0000 (09:27 -0400)
The intention in the original patch was to release the lock when
we put the inode, however something got screwed up.

Reported-by: Jason Yan <yanaijie@huawei.com>
Fixes: 7b410d9ce460f ("pNFS: Delay getting the layout header in..")
Cc: stable@vger.kernel.org # v4.10+
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/callback_proc.c

index e7f041447afdcd1584bb89fa26fa61e76d54e46c..52479f180ea1497af4f8a250db4d8c222ce8bfaa 100644 (file)
@@ -131,10 +131,11 @@ restart:
                        if (!inode)
                                continue;
                        if (!nfs_sb_active(inode->i_sb)) {
-                               rcu_read_lock();
+                               rcu_read_unlock();
                                spin_unlock(&clp->cl_lock);
                                iput(inode);
                                spin_lock(&clp->cl_lock);
+                               rcu_read_lock();
                                goto restart;
                        }
                        return inode;
@@ -170,10 +171,11 @@ restart:
                        if (!inode)
                                continue;
                        if (!nfs_sb_active(inode->i_sb)) {
-                               rcu_read_lock();
+                               rcu_read_unlock();
                                spin_unlock(&clp->cl_lock);
                                iput(inode);
                                spin_lock(&clp->cl_lock);
+                               rcu_read_lock();
                                goto restart;
                        }
                        return inode;