Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8830e60 authored by Miao Xie's avatar Miao Xie Committed by Chris Mason
Browse files

Btrfs: fix memory leak in start_transaction()



This patch fixes memory leak of the transaction handle which happened
when starting transaction failed on a freezed fs.

Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
parent d24bec3a
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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);
	}