On Tue, 8 Mar 2011 17:14:59 +0800 Bob Liu <lliubbo@xxxxxxxxx> wrote: > 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: Is this correct? We've linked the inode to the dentry with d_instantiate(), so the d_put() will do the iput() on the inode. -- 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>