linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] shmem: put inode if alloc_file failed
@ 2011-03-08  9:14 Bob Liu
  2011-03-08  9:15 ` [PATCH] shmem: using goto to replace several return Bob Liu
  2011-03-09 22:58 ` [PATCH] shmem: put inode if alloc_file failed Andrew Morton
  0 siblings, 2 replies; 7+ messages in thread
From: Bob Liu @ 2011-03-08  9:14 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, viro, hch, hughd, npiggin, Bob Liu

Currently if alloc_file failed, inode willn't be put which may cause small
memory leak, this patch fix it.

Signed-off-by: Bob Liu <lliubbo@gmail.com>
---
 mm/shmem.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 7c9cdc6..1e2bea7 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2756,17 +2756,19 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
 #ifndef CONFIG_MMU
 	error = ramfs_nommu_expand_for_mapping(inode, size);
 	if (error)
-		goto put_dentry;
+		goto put_inode;
 #endif
 
 	error = -ENFILE;
 	file = alloc_file(&path, FMODE_WRITE | FMODE_READ,
 		  &shmem_file_operations);
 	if (!file)
-		goto put_dentry;
+		goto put_inode;
 
 	return file;
 
+put_inode:
+	iput(inode);
 put_dentry:
 	path_put(&path);
 put_memory:
-- 
1.6.3.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-03-11 10:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-08  9:14 [PATCH] shmem: put inode if alloc_file failed Bob Liu
2011-03-08  9:15 ` [PATCH] shmem: using goto to replace several return Bob Liu
2011-03-09 23:01   ` Andrew Morton
2011-03-09 22:58 ` [PATCH] shmem: put inode if alloc_file failed Andrew Morton
2011-03-10  0:03   ` Al Viro
2011-03-11 10:12     ` Bob Liu
2011-03-11 10:20     ` Bob Liu

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).