mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-30 09:21:45 +00:00
btrfs-progs: fix memory leak on error path
dev_scans and t_scans should be freed on malloc error. Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
529f5c5854
commit
140592187b
@ -846,11 +846,16 @@ static int scan_devices(struct recover_control *rc)
|
||||
if (!dev_scans)
|
||||
return -ENOMEM;
|
||||
t_scans = (pthread_t *)malloc(sizeof(pthread_t) * devnr);
|
||||
if (!t_scans)
|
||||
if (!t_scans) {
|
||||
free(dev_scans);
|
||||
return -ENOMEM;
|
||||
}
|
||||
t_rets = (long *)malloc(sizeof(long) * devnr);
|
||||
if (!t_rets)
|
||||
if (!t_rets) {
|
||||
free(dev_scans);
|
||||
free(t_scans);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
list_for_each_entry(dev, &rc->fs_devices->devices, dev_list) {
|
||||
fd = open(dev->name, O_RDONLY);
|
||||
|
Loading…
Reference in New Issue
Block a user