diff options
author | Jesper Juhl <jj@chaosbits.net> | 2010-12-24 17:22:37 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-01-04 13:10:36 -0500 |
commit | 878215feb8b2417c4700090b4335739858cf7b5a (patch) | |
tree | 175172dad3e31faf4cb36262f3ef5fdf2a7bda61 /fs/nfs/proc.c | |
parent | 1174dd1f890b7f8be8ec6a7071657fe8f59e18b7 (diff) |
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: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/proc.c')
-rw-r--r-- | fs/nfs/proc.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index 00df60523aac..77d5e21c4ad6 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c | |||
@@ -458,7 +458,7 @@ nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, | |||
458 | fattr = nfs_alloc_fattr(); | 458 | fattr = nfs_alloc_fattr(); |
459 | status = -ENOMEM; | 459 | status = -ENOMEM; |
460 | if (fh == NULL || fattr == NULL) | 460 | if (fh == NULL || fattr == NULL) |
461 | goto out; | 461 | goto out_free; |
462 | 462 | ||
463 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 463 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
464 | nfs_mark_for_revalidate(dir); | 464 | nfs_mark_for_revalidate(dir); |
@@ -471,6 +471,7 @@ nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, | |||
471 | if (status == 0) | 471 | if (status == 0) |
472 | status = nfs_instantiate(dentry, fh, fattr); | 472 | status = nfs_instantiate(dentry, fh, fattr); |
473 | 473 | ||
474 | out_free: | ||
474 | nfs_free_fattr(fattr); | 475 | nfs_free_fattr(fattr); |
475 | nfs_free_fhandle(fh); | 476 | nfs_free_fhandle(fh); |
476 | out: | 477 | out: |