[PATCH] shmem: put inode if alloc_file failed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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@xxxxxxxxxx  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@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]