btrfs_alloc_chunk() unconditionally BUGs on any error returned from
__finish_chunk_alloc() so there's no need for two BUG_ON lines. Remove the
one from __finish_chunk_alloc().
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
                device = map->stripes[index].dev;
                device->bytes_used += stripe_size;
                ret = btrfs_update_device(trans, device);
-               BUG_ON(ret);
+               if (ret)
+                       goto out_free;
                index++;
        }
 
                                             item_size);
        }
 
+out_free:
        kfree(chunk);
        return ret;
 }