Skip to content

Commit 92900e5

Browse files
Al Virokdave
authored andcommitted
btrfs: fix potential oops in device_list_add
alloc_fs_devices() can return ERR_PTR(-ENOMEM), so dereferencing its result before the check for IS_ERR() is a bad idea. Fixes: d1a6300 ("btrfs: add members to fs_devices to track fsid changes") Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 302167c commit 92900e5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/btrfs/volumes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,11 +957,11 @@ static noinline struct btrfs_device *device_list_add(const char *path,
957957
else
958958
fs_devices = alloc_fs_devices(disk_super->fsid, NULL);
959959

960-
fs_devices->fsid_change = fsid_change_in_progress;
961-
962960
if (IS_ERR(fs_devices))
963961
return ERR_CAST(fs_devices);
964962

963+
fs_devices->fsid_change = fsid_change_in_progress;
964+
965965
mutex_lock(&fs_devices->device_list_mutex);
966966
list_add(&fs_devices->fs_list, &fs_uuids);
967967

0 commit comments

Comments
 (0)