btrfs-progs: fix memory leak with missing device

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>
master
Justin Maggard 2016-07-28 10:44:11 -07:00 committed by David Sterba
parent af1812090b
commit c52762b4c6
1 changed files with 2 additions and 0 deletions

View File

@ -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);
}
}