提交 e0b27d98 编写于 作者: C Colin Ian King 提交者: 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: NColin Ian King <colin.king@canonical.com>
Signed-off-by: NAnna Schumaker <Anna.Schumaker@Netapp.com>
上级 474c4f30
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册