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

hints: free hint list in error exit path

This commit is contained in:
David Teigland 2020-03-03 12:25:34 -06:00
parent c392ccaa47
commit f50e7ce76c
3 changed files with 16 additions and 12 deletions

View File

@ -356,6 +356,16 @@ void hints_exit(struct cmd_context *cmd)
return _unlock_hints(cmd);
}
void free_hints(struct dm_list *hints)
{
struct hint *hint, *hint2;
dm_list_iterate_items_safe(hint, hint2, hints) {
dm_list_del(&hint->list);
free(hint);
}
}
static struct hint *_find_hint_name(struct dm_list *hints, const char *name)
{
struct hint *hint;
@ -787,8 +797,10 @@ static int _read_hint_file(struct cmd_context *cmd, struct dm_list *hints, int *
if (fclose(fp))
stack;
if (!ret)
if (!ret) {
free_hints(hints);
return 0;
}
if (!found)
return 1;

View File

@ -24,6 +24,8 @@ struct hint {
unsigned chosen:1; /* this hint's dev was chosen for scanning */
};
void free_hints(struct dm_list *hints);
int write_hint_file(struct cmd_context *cmd, int newhints);
void clear_hint_file(struct cmd_context *cmd);

View File

@ -857,16 +857,6 @@ static int _setup_bcache(void)
return 1;
}
static void _free_hints(struct dm_list *hints)
{
struct hint *hint, *hint2;
dm_list_iterate_items_safe(hint, hint2, hints) {
dm_list_del(&hint->list);
free(hint);
}
}
/*
* We don't know how many of num_devs will be PVs that we need to
* keep open, but if it's greater than the soft limit, then we'll
@ -1165,7 +1155,7 @@ int label_scan(struct cmd_context *cmd)
if (!validate_hints(cmd, &hints_list)) {
log_debug("Will scan %d remaining devices", dm_list_size(&all_devs));
_scan_list(cmd, cmd->filter, &all_devs, NULL);
_free_hints(&hints_list);
free_hints(&hints_list);
using_hints = 0;
create_hints = 0;
} else {