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

Commit 917c16b2 authored by Chris Mason's avatar Chris Mason
Browse files

Btrfs: fix oops on NULL trans handle in btrfs_truncate



If we fail to reserve space in the transaction during truncate, we can
error out with a NULL trans handle.  The cleanup code needs an extra
check to make sure we aren't trying to use the bad handle.

Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 45ea6095
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -6529,6 +6529,7 @@ static int btrfs_truncate(struct inode *inode)
		ret = btrfs_orphan_del(NULL, inode);
	}

	if (trans) {
		trans->block_rsv = &root->fs_info->trans_block_rsv;
		ret = btrfs_update_inode(trans, root, inode);
		if (ret && !err)
@@ -6537,6 +6538,7 @@ static int btrfs_truncate(struct inode *inode)
		nr = trans->blocks_used;
		ret = btrfs_end_transaction_throttle(trans, root);
		btrfs_btree_balance_dirty(root, nr);
	}

out:
	btrfs_free_block_rsv(root, rsv);