提交 878215fe 编写于 作者: J Jesper Juhl 提交者: Trond Myklebust

NFS: Don't leak in nfs_proc_symlink()

Hi,

In fs/nfs/proc.c::nfs_proc_symlink() we will leak memory if either
nfs_alloc_fhandle() or nfs_alloc_fattr() returns NULL but the other one
doesn't.
This patch ensures memory allocated by one when the other fails is always
released (this is safe since nfs_free_fattr() and nfs_free_fhandle() both
call kfree which deals gracefully with NULL pointers).
Signed-off-by: NJesper Juhl <jj@chaosbits.net>
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 1174dd1f
...@@ -458,7 +458,7 @@ nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, ...@@ -458,7 +458,7 @@ nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page,
fattr = nfs_alloc_fattr(); fattr = nfs_alloc_fattr();
status = -ENOMEM; status = -ENOMEM;
if (fh == NULL || fattr == NULL) if (fh == NULL || fattr == NULL)
goto out; goto out_free;
status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
nfs_mark_for_revalidate(dir); nfs_mark_for_revalidate(dir);
...@@ -471,6 +471,7 @@ nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, ...@@ -471,6 +471,7 @@ nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page,
if (status == 0) if (status == 0)
status = nfs_instantiate(dentry, fh, fattr); status = nfs_instantiate(dentry, fh, fattr);
out_free:
nfs_free_fattr(fattr); nfs_free_fattr(fattr);
nfs_free_fhandle(fh); nfs_free_fhandle(fh);
out: out:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册