NFSv4: Fix a credential leak in _nfs4_discover_trunking()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 27 Oct 2022 20:50:12 +0000 (16:50 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 28 Nov 2022 03:09:59 +0000 (22:09 -0500)
Fixes: 4f40a5b55446 ("NFSv4: Add an fattr allocation to _nfs4_discover_trunking()")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/nfs4proc.c

index 98a8670..bd89c7f 100644 (file)
@@ -4018,7 +4018,7 @@ static int _nfs4_discover_trunking(struct nfs_server *server,
 
        page = alloc_page(GFP_KERNEL);
        if (!page)
-               return -ENOMEM;
+               goto out_put_cred;
        locations = kmalloc(sizeof(struct nfs4_fs_locations), GFP_KERNEL);
        if (!locations)
                goto out_free;
@@ -4040,6 +4040,8 @@ out_free_2:
        kfree(locations);
 out_free:
        __free_page(page);
+out_put_cred:
+       put_cred(cred);
        return status;
 }