NFS: Cleanup if nfs_match_client is interrupted [Linux 4.14.136]

This Linux kernel change "NFS: Cleanup if nfs_match_client is interrupted" is included in the Linux 4.14.136 release. This change is authored by Benjamin Coddington <bcodding [at] redhat.com> on Tue Jun 11 12:57:52 2019 -0400. The commit for this change in Linux stable tree is 4f694fa (patch) which is from upstream commit 9f7761c. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 9f7761c.

NFS: Cleanup if nfs_match_client is interrupted

commit 9f7761cf0409465075dadb875d5d4b8ef2f890c8 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

There are 4 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 fs/nfs/client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 0c7008f..9e7d49f 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -416,10 +416,10 @@ struct nfs_client *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) {

Leave a Reply

Your email address will not be published. Required fields are marked *