btrfs: fix null pointer deref when target device is missing
[sfrench/cifs-2.6.git] / fs / btrfs / dev-replace.c
index dd717e204b5e104bde541e6dfcc0eade543c9ba1..c523478b3de2298e45c5b58e8671b9b58b499fac 100644 (file)
@@ -312,7 +312,7 @@ void btrfs_after_dev_replace_commit(struct btrfs_fs_info *fs_info)
 
 static char* btrfs_dev_name(struct btrfs_device *device)
 {
-       if (test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state))
+       if (!device || test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state))
                return "<missing disk>";
        else
                return rcu_str_deref(device->name);