Message ID | 1302316207-30806-1-git-send-email-yoshinori.sano@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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: ... -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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); }
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(-)