[RHEL7,COMMIT] ms/NFS: Cleanup if nfs_match_client is interrupted

Submitted by Konstantin Khorenko on Oct. 3, 2019, 3:47 p.m.

Details

Message ID 201910031547.x93FlKXJ011346@finist-ce7.sw.ru
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko Oct. 3, 2019, 3:47 p.m.
The commit is pushed to "branch-rh7-3.10.0-957.27.2.vz7.107.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.27.2.vz7.107.13
------>
commit 7888f89d2b4bd5287c6930d943351a95ff642ed1
Author: Benjamin Coddington <bcodding@redhat.com>
Date:   Thu Oct 3 18:47:20 2019 +0300

    ms/NFS: Cleanup if nfs_match_client is interrupted
    
    Don't bail out before cleaning up a new allocation if the wait for
    searching for a matching nfs client is interrupted.  Memory leaks.
    
    Reported-by: syzbot+7fe11b49c1cc30e3fce2@syzkaller.appspotmail.com
    Fixes: 950a578c6128 ("NFS: make nfs_match_client killable")
    Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    
    https://jira.sw.ru/browse/PSBM-98297
    (cherry picked from commit 9f7761cf0409465075dadb875d5d4b8ef2f890c8)
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 fs/nfs/client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index e9e23421a36e..24d025fcbb6a 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -429,10 +429,10 @@  nfs_get_client(const struct nfs_client_initdata *cl_init,
 		clp = nfs_match_client(cl_init);
 		if (clp) {
 			spin_unlock(&nn->nfs_client_lock);
-			if (IS_ERR(clp))
-				return clp;
 			if (new)
 				new->rpc_ops->free_client(new);
+			if (IS_ERR(clp))
+				return clp;
 			return nfs_found_client(cl_init, clp);
 		}
 		if (new) {