Commit e0b27d98 authored by Colin Ian King's avatar Colin Ian King Committed by Anna Schumaker

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: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent 474c4f30
...@@ -137,6 +137,9 @@ static int nfs4_validate_fspath(struct dentry *dentry, ...@@ -137,6 +137,9 @@ static int nfs4_validate_fspath(struct dentry *dentry,
int n; int n;
buf = kmalloc(4096, GFP_KERNEL); buf = kmalloc(4096, GFP_KERNEL);
if (!buf)
return -ENOMEM;
path = nfs4_path(dentry, buf, 4096); path = nfs4_path(dentry, buf, 4096);
if (IS_ERR(path)) { if (IS_ERR(path)) {
kfree(buf); kfree(buf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment