aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2020-01-06 13:17:34 +0000
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2020-01-15 10:54:31 -0500
commite0b27d98bfed9cd9a22f96996bab24858646883d (patch)
treee6963ce458c9b8d23abf96acdc7a2d48188c543d /fs/nfs
parentnfs: NFS_SWAP should depend on SWAP (diff)
downloadlinux-dev-e0b27d98bfed9cd9a22f96996bab24858646883d.tar.xz
linux-dev-e0b27d98bfed9cd9a22f96996bab24858646883d.zip
NFS: Add missing null check for failed allocation
Currently the allocation of buf is not being null checked and a null pointer dereference can occur when the memory allocation fails. Fix this by adding a check and returning -ENOMEM. Addresses-Coverity: ("Dereference null return") Fixes: 6d972518b821 ("NFS: Add fs_context support.") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/nfs4namespace.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
index 10e9e1887841..de6875a9b391 100644
--- a/fs/nfs/nfs4namespace.c
+++ b/fs/nfs/nfs4namespace.c
@@ -137,6 +137,9 @@ static int nfs4_validate_fspath(struct dentry *dentry,
int n;
buf = kmalloc(4096, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
path = nfs4_path(dentry, buf, 4096);
if (IS_ERR(path)) {
kfree(buf);