Skip to content

Commit 29cc83f

Browse files
Liu Bomasoncl
authored andcommitted
Btrfs: fix NULL pointer crash of deleting a seed device
Same as normal devices, seed devices should be initialized with fs_info->dev_root as well, otherwise we'll get a NULL pointer crash. Cc: Chris Murphy <lists@colorremedies.com> Reported-by: Chris Murphy <lists@colorremedies.com> Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: Chris Mason <clm@fb.com>
1 parent f017f15 commit 29cc83f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

fs/btrfs/volumes.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6146,10 +6146,14 @@ void btrfs_init_devices_late(struct btrfs_fs_info *fs_info)
61466146
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
61476147
struct btrfs_device *device;
61486148

6149-
mutex_lock(&fs_devices->device_list_mutex);
6150-
list_for_each_entry(device, &fs_devices->devices, dev_list)
6151-
device->dev_root = fs_info->dev_root;
6152-
mutex_unlock(&fs_devices->device_list_mutex);
6149+
while (fs_devices) {
6150+
mutex_lock(&fs_devices->device_list_mutex);
6151+
list_for_each_entry(device, &fs_devices->devices, dev_list)
6152+
device->dev_root = fs_info->dev_root;
6153+
mutex_unlock(&fs_devices->device_list_mutex);
6154+
6155+
fs_devices = fs_devices->seed;
6156+
}
61536157
}
61546158

61556159
static void __btrfs_reset_dev_stats(struct btrfs_device *dev)

0 commit comments

Comments
 (0)