diff options
author | Younger Liu <younger.liu@huawei.com> | 2013-09-11 17:19:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-11 18:56:47 -0400 |
commit | 6ea437a3639b15e312f81819bb20f737ff596194 (patch) | |
tree | 4597c89df18548437a555660bf41adf076d1d908 /fs/ocfs2/xattr.c | |
parent | 17caf9555edc27a0c6df512de0879b357ebacae4 (diff) |
ocfs2: free meta_ac and data_ac when ocfs2_start_trans fails in ocfs2_xattr_set()
In ocfs2_xattr_set(), if ocfs2_start_trans failed, meta_ac and data_ac
should be free. Otherwise, It would lead to a memory leak.
Signed-off-by: Younger Liu <younger.liu@huawei.com>
Cc: Joseph Qi <joseph.qi@huawei.com>
Reviewed-by: Jie Liu <jeff.liu@oracle.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ocfs2/xattr.c')
-rw-r--r-- | fs/ocfs2/xattr.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 1cbc2231a9f2..18330f5b57be 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -3505,7 +3505,7 @@ int ocfs2_xattr_set(struct inode *inode, | |||
3505 | int ret, credits, ref_meta = 0, ref_credits = 0; | 3505 | int ret, credits, ref_meta = 0, ref_credits = 0; |
3506 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 3506 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
3507 | struct inode *tl_inode = osb->osb_tl_inode; | 3507 | struct inode *tl_inode = osb->osb_tl_inode; |
3508 | struct ocfs2_xattr_set_ctxt ctxt = { NULL, NULL, }; | 3508 | struct ocfs2_xattr_set_ctxt ctxt = { NULL, NULL, NULL, }; |
3509 | struct ocfs2_refcount_tree *ref_tree = NULL; | 3509 | struct ocfs2_refcount_tree *ref_tree = NULL; |
3510 | 3510 | ||
3511 | struct ocfs2_xattr_info xi = { | 3511 | struct ocfs2_xattr_info xi = { |
@@ -3609,13 +3609,14 @@ int ocfs2_xattr_set(struct inode *inode, | |||
3609 | if (IS_ERR(ctxt.handle)) { | 3609 | if (IS_ERR(ctxt.handle)) { |
3610 | ret = PTR_ERR(ctxt.handle); | 3610 | ret = PTR_ERR(ctxt.handle); |
3611 | mlog_errno(ret); | 3611 | mlog_errno(ret); |
3612 | goto cleanup; | 3612 | goto out_free_ac; |
3613 | } | 3613 | } |
3614 | 3614 | ||
3615 | ret = __ocfs2_xattr_set_handle(inode, di, &xi, &xis, &xbs, &ctxt); | 3615 | ret = __ocfs2_xattr_set_handle(inode, di, &xi, &xis, &xbs, &ctxt); |
3616 | 3616 | ||
3617 | ocfs2_commit_trans(osb, ctxt.handle); | 3617 | ocfs2_commit_trans(osb, ctxt.handle); |
3618 | 3618 | ||
3619 | out_free_ac: | ||
3619 | if (ctxt.data_ac) | 3620 | if (ctxt.data_ac) |
3620 | ocfs2_free_alloc_context(ctxt.data_ac); | 3621 | ocfs2_free_alloc_context(ctxt.data_ac); |
3621 | if (ctxt.meta_ac) | 3622 | if (ctxt.meta_ac) |