Btrfs: check return value of open_bdev_exclusive properly
authorJosef Bacik <josef@redhat.com>
Wed, 27 Jan 2010 02:09:00 +0000 (02:09 +0000)
committerChris Mason <chris.mason@oracle.com>
Thu, 28 Jan 2010 21:20:39 +0000 (16:20 -0500)
Hit this problem while testing RAID1 failure stuff.  open_bdev_exclusive
returns ERR_PTR(), not NULL.  So change the return value properly.  This
is important if you accidently specify a device that doesn't exist when
trying to add a new device to an array, you will panic the box
dereferencing bdev.

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/volumes.c

index 66122bdf8bbf81ca50103e7a1dd54cb8fa294a91..5eb7459e3782f8871d4b6c6e4286aa4671f410c6 100644 (file)
@@ -1434,8 +1434,8 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
                return -EINVAL;
 
        bdev = open_bdev_exclusive(device_path, 0, root->fs_info->bdev_holder);
-       if (!bdev)
-               return -EIO;
+       if (IS_ERR(bdev))
+               return PTR_ERR(bdev);
 
        if (root->fs_info->fs_devices->seeding) {
                seeding_dev = 1;