btrfs-progs: don't access freed memory in btrfs_close_devices
authorDavid Sterba <dsterba@suse.com>
Mon, 3 Oct 2016 14:48:53 +0000 (16:48 +0200)
committerDavid Sterba <dsterba@suse.com>
Wed, 5 Oct 2016 10:39:01 +0000 (12:39 +0200)
Caught by ASAN, as we don't access fs_devices directly, there's no null
deref but 0x30 is still wrong.

Signed-off-by: David Sterba <dsterba@suse.com>
volumes.c

index da79751..b9ca550 100644 (file)
--- a/volumes.c
+++ b/volumes.c
@@ -162,6 +162,8 @@ int btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
        struct btrfs_device *device;
 
 again:
+       if (!fs_devices)
+               return 0;
        while (!list_empty(&fs_devices->devices)) {
                device = list_entry(fs_devices->devices.next,
                                    struct btrfs_device, dev_list);