btrfs-progs: fix memory leak with missing device
authorJustin Maggard <jmaggard10@gmail.com>
Thu, 28 Jul 2016 17:44:11 +0000 (10:44 -0700)
committerDavid Sterba <dsterba@suse.com>
Fri, 29 Jul 2016 13:04:54 +0000 (15:04 +0200)
In read_one_chunk(), we may add an empty entry for a missing device.
However, this entry wasn't being added to the dev_list, and so it never
got freed.

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

index 26bf6c5..a356d74 100644 (file)
--- a/volumes.c
+++ b/volumes.c
@@ -1761,6 +1761,8 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
                        map->stripes[i].dev = fill_missing_device(devid);
                        printf("warning, device %llu is missing\n",
                               (unsigned long long)devid);
+                       list_add(&map->stripes[i].dev->dev_list,
+                                &root->fs_info->fs_devices->devices);
                }
 
        }