btrfs: don't BUG_ON allocation errors in btrfs_drop_snapshot
authorMark Fasheh <mfasheh@suse.com>
Wed, 13 Jul 2011 17:59:59 +0000 (10:59 -0700)
committerMark Fasheh <mfasheh@suse.com>
Mon, 25 Jul 2011 21:35:15 +0000 (14:35 -0700)
In addition to properly handling allocation failure from btrfs_alloc_path, I
also fixed up the kzalloc error handling code immediately below it.

Signed-off-by: Mark Fasheh <mfasheh@suse.com>
fs/btrfs/extent-tree.c

index f6af4236e59be09aa3c9bc341c998e3bb5933d47..6bce721e7bbc9fe6b5c12a6f92513b8fcbdb4455 100644 (file)
@@ -6272,10 +6272,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
        int level;
 
        path = btrfs_alloc_path();
-       BUG_ON(!path);
+       if (!path)
+               return -ENOMEM;
 
        wc = kzalloc(sizeof(*wc), GFP_NOFS);
-       BUG_ON(!wc);
+       if (!wc) {
+               btrfs_free_path(path);
+               return -ENOMEM;
+       }
 
        trans = btrfs_start_transaction(tree_root, 0);
        BUG_ON(IS_ERR(trans));