1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

cov: fix iter memleak in vgimportclose

Add missing release of iterator on error path.
This commit is contained in:
Zdenek Kabelac 2021-03-10 01:25:37 +01:00
parent 131ca0eb95
commit 241c63f7a7

View File

@ -190,6 +190,7 @@ static int _get_other_devs(struct cmd_context *cmd, struct dm_list *new_devs, st
struct dev_iter *iter; struct dev_iter *iter;
struct device *dev; struct device *dev;
struct device_list *devl; struct device_list *devl;
int r = 1;
if (!(iter = dev_iter_create(cmd->filter, 0))) if (!(iter = dev_iter_create(cmd->filter, 0)))
return_0; return_0;
@ -197,14 +198,16 @@ static int _get_other_devs(struct cmd_context *cmd, struct dm_list *new_devs, st
while ((dev = dev_iter_get(cmd, iter))) { while ((dev = dev_iter_get(cmd, iter))) {
if (_get_device_list(new_devs, dev)) if (_get_device_list(new_devs, dev))
continue; continue;
if (!(devl = malloc(sizeof(*devl)))) if (!(devl = malloc(sizeof(*devl)))) {
return_0; r = 0;
goto_bad;
}
devl->dev = dev; devl->dev = dev;
dm_list_add(other_devs, &devl->list); dm_list_add(other_devs, &devl->list);
} }
bad:
dev_iter_destroy(iter); dev_iter_destroy(iter);
return 1; return r;
} }
int vgimportclone(struct cmd_context *cmd, int argc, char **argv) int vgimportclone(struct cmd_context *cmd, int argc, char **argv)