linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] NFS: Don't leak in nfs_proc_symlink()
@ 2010-12-24 22:22 Jesper Juhl
  0 siblings, 0 replies; only message in thread
From: Jesper Juhl @ 2010-12-24 22:22 UTC (permalink / raw)
  To: linux-nfs; +Cc: Trond Myklebust, linux-kernel

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>
---
 proc.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index 58e7f84..9e81d9b 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,
 	fattr = nfs_alloc_fattr();
 	status = -ENOMEM;
 	if (fh == NULL || fattr == NULL)
-		goto out;
+		goto out_free;
 
 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
 	nfs_mark_for_revalidate(dir);
@@ -471,6 +471,7 @@ nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page,
 	if (status == 0)
 		status = nfs_instantiate(dentry, fh, fattr);
 
+out_free:
 	nfs_free_fattr(fattr);
 	nfs_free_fhandle(fh);
 out:



-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-12-24 22:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-24 22:22 [PATCH] NFS: Don't leak in nfs_proc_symlink() Jesper Juhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).