From: Andrew Morton <akpm@linux-foundation.org>
To: Bob Liu <lliubbo@gmail.com>
Cc: linux-mm@kvack.org, viro@zeniv.linux.org.uk, hch@lst.de,
hughd@google.com, npiggin@kernel.dk
Subject: Re: [PATCH] shmem: put inode if alloc_file failed
Date: Wed, 9 Mar 2011 14:58:59 -0800 [thread overview]
Message-ID: <20110309145859.dbe31df5.akpm@linux-foundation.org> (raw)
In-Reply-To: <1299575700-6901-1-git-send-email-lliubbo@gmail.com>
On Tue, 8 Mar 2011 17:14:59 +0800
Bob Liu <lliubbo@gmail.com> 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@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:
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@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>
next prev parent reply other threads:[~2011-03-09 22:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Andrew Morton [this message]
2011-03-10 0:03 ` [PATCH] shmem: put inode if alloc_file failed Al Viro
2011-03-11 10:12 ` Bob Liu
2011-03-11 10:20 ` Bob Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110309145859.dbe31df5.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=hch@lst.de \
--cc=hughd@google.com \
--cc=linux-mm@kvack.org \
--cc=lliubbo@gmail.com \
--cc=npiggin@kernel.dk \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).