diff --git a/Assemble.c b/Assemble.c index 32e6f6f..5a907c1 100644 --- a/Assemble.c +++ b/Assemble.c @@ -1851,8 +1851,8 @@ try_again: if (rv == 1 && !pre_exist) ioctl(mdfd, STOP_ARRAY, NULL); free(devices); - map_unlock(&map); out: + map_unlock(&map); if (rv == 0) { wait_for(chosen_name, mdfd); close(mdfd); diff --git a/Detail.c b/Detail.c index 860241c..b3e857a 100644 --- a/Detail.c +++ b/Detail.c @@ -263,6 +263,7 @@ int Detail(char *dev, struct context *c) if (st->ss->export_detail_super) st->ss->export_detail_super(st); + map_free(map); } else { struct map_ent *mp, *map = NULL; char nbuf[64]; @@ -277,6 +278,7 @@ int Detail(char *dev, struct context *c) print_escape(mp->path+8); putchar('\n'); } + map_free(map); } if (sra) { struct mdinfo *mdi; diff --git a/Incremental.c b/Incremental.c index 0beab16..0c5698e 100644 --- a/Incremental.c +++ b/Incremental.c @@ -1413,6 +1413,7 @@ restart: sysfs_free(sra); } } + map_free(mapl); return rv; } @@ -1587,6 +1588,8 @@ static int Incremental_container(struct supertype *st, char *devname, assemble_container_content(st, mdfd, ra, c, chosen_name, &result); + map_free(map); + map = NULL; close(mdfd); } if (c->export && result) { @@ -1663,6 +1666,7 @@ static int Incremental_container(struct supertype *st, char *devname, close(sfd); } domain_free(domains); + map_free(map); return 0; } diff --git a/config.c b/config.c index 48e0278..e14eae0 100644 --- a/config.c +++ b/config.c @@ -181,9 +181,10 @@ struct mddev_dev *load_containers(void) } d->next = rv; rv = d; + map_free(map); + map = NULL; } free_mdstat(mdstat); - map_free(map); return rv; } diff --git a/mapfile.c b/mapfile.c index f3c8191..a502556 100644 --- a/mapfile.c +++ b/mapfile.c @@ -143,6 +143,8 @@ void map_unlock(struct map_ent **melp) unlink(mapname[2]); fclose(lf); } + if (*melp) + map_free(*melp); lf = NULL; } diff --git a/mdadm.c b/mdadm.c index 5afe415..1cf5c18 100644 --- a/mdadm.c +++ b/mdadm.c @@ -1885,6 +1885,8 @@ static int misc_scan(char devmode, struct context *c) else rv |= WaitClean(name, c->verbose); put_md_name(name); + map_free(map); + map = NULL; } } free_mdstat(ms);