Skip to content

Commit

Permalink
Btrfs: fix memory leak in start_transaction()
Browse files Browse the repository at this point in the history
This patch fixes memory leak of the transaction handle which happened
when starting transaction failed on a freezed fs.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
  • Loading branch information
Miao Xie authored and Chris Mason committed Oct 9, 2012
1 parent d24bec3 commit e8830e6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/btrfs/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,10 @@ static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root,
*/
if (type != TRANS_JOIN_NOLOCK &&
!__sb_start_write(root->fs_info->sb, SB_FREEZE_FS, false)) {
if (type == TRANS_JOIN_FREEZE)
if (type == TRANS_JOIN_FREEZE) {
kmem_cache_free(btrfs_trans_handle_cachep, h);
return ERR_PTR(-EPERM);
}
sb_start_intwrite(root->fs_info->sb);
}

Expand Down

0 comments on commit e8830e6

Please sign in to comment.