Merge remote-tracking branches 'regulator/topic/lp8755', 'regulator/topic/ltc3589...
[firefly-linux-kernel-4.4.55.git] / fs / btrfs / volumes.c
index 6104676857f5c6567bcbb5a375cb91e90a78956f..6cb82f62cb7c22c4b3038e248e52b9694171a5bd 100644 (file)
@@ -1680,11 +1680,11 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
        if (device->bdev == root->fs_info->fs_devices->latest_bdev)
                root->fs_info->fs_devices->latest_bdev = next_device->bdev;
 
-       if (device->bdev)
+       if (device->bdev) {
                device->fs_devices->open_devices--;
-
-       /* remove sysfs entry */
-       btrfs_kobj_rm_device(root->fs_info, device);
+               /* remove sysfs entry */
+               btrfs_kobj_rm_device(root->fs_info, device);
+       }
 
        call_rcu(&device->rcu, free_device);