]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
btrfs: use proper error values on allocation failure in clone_fs_devices
authorAnand Jain <anand.jain@oracle.com>
Tue, 27 Aug 2019 07:40:45 +0000 (15:40 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 9 Sep 2019 12:59:14 +0000 (14:59 +0200)
Fix the fake ENOMEM return error code to the actual error in
clone_fs_devices().

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c

index c7a08fe2667226fe19e501e64f1a0c73170047f9..8bfc41f1b3b63c235b4775c63a270a880641587b 100644 (file)
@@ -1115,6 +1115,7 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig)
        struct btrfs_fs_devices *fs_devices;
        struct btrfs_device *device;
        struct btrfs_device *orig_dev;
+       int ret = 0;
 
        fs_devices = alloc_fs_devices(orig->fsid, NULL);
        if (IS_ERR(fs_devices))
@@ -1128,8 +1129,10 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig)
 
                device = btrfs_alloc_device(NULL, &orig_dev->devid,
                                            orig_dev->uuid);
-               if (IS_ERR(device))
+               if (IS_ERR(device)) {
+                       ret = PTR_ERR(device);
                        goto error;
+               }
 
                /*
                 * This is ok to do without rcu read locked because we hold the
@@ -1140,6 +1143,7 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig)
                                        GFP_KERNEL);
                        if (!name) {
                                btrfs_free_device(device);
+                               ret = -ENOMEM;
                                goto error;
                        }
                        rcu_assign_pointer(device->name, name);
@@ -1154,7 +1158,7 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig)
 error:
        mutex_unlock(&orig->device_list_mutex);
        free_fs_devices(fs_devices);
-       return ERR_PTR(-ENOMEM);
+       return ERR_PTR(ret);
 }
 
 /*