]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
Btrfs: fix oops on NULL trans handle in btrfs_truncate
authorChris Mason <chris.mason@oracle.com>
Tue, 8 Nov 2011 19:49:59 +0000 (14:49 -0500)
committerChris Mason <chris.mason@oracle.com>
Tue, 8 Nov 2011 19:49:59 +0000 (14:49 -0500)
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: Chris Mason <chris.mason@oracle.com>
fs/btrfs/inode.c

index 9d0eaa57d4ee357f0eb14495dbdc55b76fc6c8d8..f60e2490bd0d05a727a3098a2fb884440b0066c3 100644 (file)
@@ -6529,14 +6529,16 @@ end_trans:
                ret = btrfs_orphan_del(NULL, inode);
        }
 
-       trans->block_rsv = &root->fs_info->trans_block_rsv;
-       ret = btrfs_update_inode(trans, root, inode);
-       if (ret && !err)
-               err = ret;
+       if (trans) {
+               trans->block_rsv = &root->fs_info->trans_block_rsv;
+               ret = btrfs_update_inode(trans, root, inode);
+               if (ret && !err)
+                       err = ret;
 
-       nr = trans->blocks_used;
-       ret = btrfs_end_transaction_throttle(trans, root);
-       btrfs_btree_balance_dirty(root, nr);
+               nr = trans->blocks_used;
+               ret = btrfs_end_transaction_throttle(trans, root);
+               btrfs_btree_balance_dirty(root, nr);
+       }
 
 out:
        btrfs_free_block_rsv(root, rsv);