Btrfs-progs: skip open devices which is missing
authorLiu Bo <bo.li.liu@oracle.com>
Sat, 22 Jun 2013 05:32:42 +0000 (13:32 +0800)
committerChris Mason <chris.mason@fusionio.com>
Wed, 3 Jul 2013 18:16:09 +0000 (14:16 -0400)
A device can be added to the device list without getting a name, so we may
access to illegal addresses while opening devices with their name.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
volumes.c

index d6f81f8..013bfd5 100644 (file)
--- a/volumes.c
+++ b/volumes.c
@@ -186,6 +186,10 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int flags)
 
        list_for_each(cur, head) {
                device = list_entry(cur, struct btrfs_device, dev_list);
+               if (!device->name) {
+                       printk("no name for device %llu, skip it now\n", device->devid);
+                       continue;
+               }
 
                fd = open(device->name, flags);
                if (fd < 0) {