* [PATCH] Btrfs: fix memory leaks in btrfs_new_inode()
@ 2011-04-09 2:30 Yoshinori Sano
2011-04-11 2:23 ` Li Zefan
0 siblings, 1 reply; 2+ messages in thread
From: Yoshinori Sano @ 2011-04-09 2:30 UTC (permalink / raw)
To: linux-btrfs; +Cc: chris.mason, Yoshinori Sano
This patch fixes memory leaks in btrfs_new_inode().
Signed-off-by: Yoshinori Sano <yoshinori.sano@gmail.com>
---
fs/btrfs/inode.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index aa116dc..d8c93c1 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4536,14 +4536,17 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
return ERR_PTR(-ENOMEM);
inode = new_inode(root->fs_info->sb);
- if (!inode)
+ if (!inode) {
+ btrfs_free_path(path);
return ERR_PTR(-ENOMEM);
+ }
if (dir) {
trace_btrfs_inode_request(dir);
ret = btrfs_set_inode_index(dir, index);
if (ret) {
+ btrfs_free_path(path);
iput(inode);
return ERR_PTR(ret);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Btrfs: fix memory leaks in btrfs_new_inode()
2011-04-09 2:30 [PATCH] Btrfs: fix memory leaks in btrfs_new_inode() Yoshinori Sano
@ 2011-04-11 2:23 ` Li Zefan
0 siblings, 0 replies; 2+ messages in thread
From: Li Zefan @ 2011-04-11 2:23 UTC (permalink / raw)
To: Yoshinori Sano; +Cc: linux-btrfs, chris.mason
Yoshinori Sano wrote:
> This patch fixes memory leaks in btrfs_new_inode().
>
> Signed-off-by: Yoshinori Sano <yoshinori.sano@gmail.com>
> ---
> fs/btrfs/inode.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index aa116dc..d8c93c1 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -4536,14 +4536,17 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
> return ERR_PTR(-ENOMEM);
>
> inode = new_inode(root->fs_info->sb);
> - if (!inode)
> + if (!inode) {
> + btrfs_free_path(path);
> return ERR_PTR(-ENOMEM);
> + }
>
> if (dir) {
> trace_btrfs_inode_request(dir);
>
> ret = btrfs_set_inode_index(dir, index);
> if (ret) {
> + btrfs_free_path(path);
> iput(inode);
> return ERR_PTR(ret);
> }
It would be better to avoid multiple returns here:
fail_free_path:
btrfs_free_path(path);
fail_put_inode:
iput(inode);
fail:
...
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-04-11 2:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-09 2:30 [PATCH] Btrfs: fix memory leaks in btrfs_new_inode() Yoshinori Sano
2011-04-11 2:23 ` Li Zefan
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).