Fix nfs_client refcounting if kmalloc fails in nfs4_proc_exchange_id and nfs4_proc_as...
authorDave Wysochanski <dwysocha@redhat.com>
Thu, 27 Apr 2017 14:45:15 +0000 (10:45 -0400)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Fri, 5 May 2017 17:01:32 +0000 (13:01 -0400)
If memory allocation fails for the callback data, we need to put the nfs_client
or we end up with an elevated refcount.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/nfs4proc.c

index 62fc8eed53ccb8c1e3d1ad5aa554d36592b33df0..f48dfb7f36916b728c7446269aea5afc7536a420 100644 (file)
@@ -4807,8 +4807,10 @@ static int nfs4_proc_async_renew(struct nfs_client *clp, struct rpc_cred *cred,
        if (!atomic_inc_not_zero(&clp->cl_count))
                return -EIO;
        data = kmalloc(sizeof(*data), GFP_NOFS);
-       if (data == NULL)
+       if (data == NULL) {
+               nfs_put_client(clp);
                return -ENOMEM;
+       }
        data->client = clp;
        data->timestamp = jiffies;
        return rpc_call_async(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT,
@@ -7454,8 +7456,10 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred,
                return -EIO;
 
        calldata = kzalloc(sizeof(*calldata), GFP_NOFS);
-       if (!calldata)
+       if (!calldata) {
+               nfs_put_client(clp);
                return -ENOMEM;
+       }
 
        if (!xprt)
                nfs4_init_boot_verifier(clp, &verifier);