diff options
author | Anand Jain <anand.jain@oracle.com> | 2019-08-27 03:40:45 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2019-09-09 08:59:14 -0400 |
commit | d2979aa25fc8de6498d906ae6b46b028457d6400 (patch) | |
tree | 8eec1aae38c552cc0d6f268e550baf4a42fd3252 | |
parent | a06dee4d7eb67c35e7b7da0b84216424d60a87d3 (diff) |
btrfs: use proper error values on allocation failure in clone_fs_devices
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>
-rw-r--r-- | fs/btrfs/volumes.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index c7a08fe26672..8bfc41f1b3b6 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -1115,6 +1115,7 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig) | |||
1115 | struct btrfs_fs_devices *fs_devices; | 1115 | struct btrfs_fs_devices *fs_devices; |
1116 | struct btrfs_device *device; | 1116 | struct btrfs_device *device; |
1117 | struct btrfs_device *orig_dev; | 1117 | struct btrfs_device *orig_dev; |
1118 | int ret = 0; | ||
1118 | 1119 | ||
1119 | fs_devices = alloc_fs_devices(orig->fsid, NULL); | 1120 | fs_devices = alloc_fs_devices(orig->fsid, NULL); |
1120 | if (IS_ERR(fs_devices)) | 1121 | if (IS_ERR(fs_devices)) |
@@ -1128,8 +1129,10 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig) | |||
1128 | 1129 | ||
1129 | device = btrfs_alloc_device(NULL, &orig_dev->devid, | 1130 | device = btrfs_alloc_device(NULL, &orig_dev->devid, |
1130 | orig_dev->uuid); | 1131 | orig_dev->uuid); |
1131 | if (IS_ERR(device)) | 1132 | if (IS_ERR(device)) { |
1133 | ret = PTR_ERR(device); | ||
1132 | goto error; | 1134 | goto error; |
1135 | } | ||
1133 | 1136 | ||
1134 | /* | 1137 | /* |
1135 | * This is ok to do without rcu read locked because we hold the | 1138 | * 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) | |||
1140 | GFP_KERNEL); | 1143 | GFP_KERNEL); |
1141 | if (!name) { | 1144 | if (!name) { |
1142 | btrfs_free_device(device); | 1145 | btrfs_free_device(device); |
1146 | ret = -ENOMEM; | ||
1143 | goto error; | 1147 | goto error; |
1144 | } | 1148 | } |
1145 | rcu_assign_pointer(device->name, name); | 1149 | rcu_assign_pointer(device->name, name); |
@@ -1154,7 +1158,7 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig) | |||
1154 | error: | 1158 | error: |
1155 | mutex_unlock(&orig->device_list_mutex); | 1159 | mutex_unlock(&orig->device_list_mutex); |
1156 | free_fs_devices(fs_devices); | 1160 | free_fs_devices(fs_devices); |
1157 | return ERR_PTR(-ENOMEM); | 1161 | return ERR_PTR(ret); |
1158 | } | 1162 | } |
1159 | 1163 | ||
1160 | /* | 1164 | /* |