fix examine_brief segfault
When performing an "-Ebs -e <metadata type>" we segfault because the superblock has been freed too early. We also leak memory for 'ddf' and 'imsm' because, unlike super[01], we do not implicitly free when ->load_super is called on an already loaded supertype. So, fix up imsm and ddf to match type 0 and 1 ->load_super() semantics, and update Examine to not free the superblock until all usages have been exhausted. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
f98d41ddb4
commit
37424f132c
|
@ -114,10 +114,8 @@ int Examine(mddev_dev_t devlist, int brief, int export, int scan,
|
||||||
ap->st = st;
|
ap->st = st;
|
||||||
arrays = ap;
|
arrays = ap;
|
||||||
st->ss->getinfo_super(st, &ap->info);
|
st->ss->getinfo_super(st, &ap->info);
|
||||||
} else {
|
} else
|
||||||
st->ss->getinfo_super(st, &ap->info);
|
st->ss->getinfo_super(st, &ap->info);
|
||||||
st->ss->free_super(st);
|
|
||||||
}
|
|
||||||
if (!(ap->info.disk.state & (1<<MD_DISK_SYNC)))
|
if (!(ap->info.disk.state & (1<<MD_DISK_SYNC)))
|
||||||
ap->spares++;
|
ap->spares++;
|
||||||
d = dl_strdup(devlist->devname);
|
d = dl_strdup(devlist->devname);
|
||||||
|
|
|
@ -762,6 +762,9 @@ static int load_ddf_local(int fd, struct ddf_super *super,
|
||||||
static int load_super_ddf_all(struct supertype *st, int fd,
|
static int load_super_ddf_all(struct supertype *st, int fd,
|
||||||
void **sbp, char *devname, int keep_fd);
|
void **sbp, char *devname, int keep_fd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void free_super_ddf(struct supertype *st);
|
||||||
|
|
||||||
static int load_super_ddf(struct supertype *st, int fd,
|
static int load_super_ddf(struct supertype *st, int fd,
|
||||||
char *devname)
|
char *devname)
|
||||||
{
|
{
|
||||||
|
@ -798,6 +801,8 @@ static int load_super_ddf(struct supertype *st, int fd,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free_super_ddf(st);
|
||||||
|
|
||||||
if (posix_memalign((void**)&super, 512, sizeof(*super))!= 0) {
|
if (posix_memalign((void**)&super, 512, sizeof(*super))!= 0) {
|
||||||
fprintf(stderr, Name ": malloc of %zu failed.\n",
|
fprintf(stderr, Name ": malloc of %zu failed.\n",
|
||||||
sizeof(*super));
|
sizeof(*super));
|
||||||
|
|
|
@ -2196,6 +2196,8 @@ static int load_super_imsm(struct supertype *st, int fd, char *devname)
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
free_super_imsm(st);
|
||||||
|
|
||||||
super = alloc_super(0);
|
super = alloc_super(0);
|
||||||
if (!super) {
|
if (!super) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
|
Loading…
Reference in New Issue