summaryrefslogtreecommitdiffstats
path: root/super-ddf.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2009-07-31 17:11:41 -0700
committerDan Williams <dan.j.williams@intel.com>2009-07-31 17:11:41 -0700
commit37424f132cb3874fe51021b1b5e04445a3ba1bdb (patch)
tree688e5aa4ce74fb01d4db529c3de46ca8fd9e1ede /super-ddf.c
parentf98d41ddb4ac543176f33454ceb70983109272d9 (diff)
downloadmdadm-37424f132cb3874fe51021b1b5e04445a3ba1bdb.tar.gz
mdadm-37424f132cb3874fe51021b1b5e04445a3ba1bdb.tar.xz
mdadm-37424f132cb3874fe51021b1b5e04445a3ba1bdb.zip
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>
Diffstat (limited to 'super-ddf.c')
-rw-r--r--super-ddf.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/super-ddf.c b/super-ddf.c
index 517a586..8153924 100644
--- a/super-ddf.c
+++ b/super-ddf.c
@@ -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,
void **sbp, char *devname, int keep_fd);
#endif
+
+static void free_super_ddf(struct supertype *st);
+
static int load_super_ddf(struct supertype *st, int fd,
char *devname)
{
@@ -798,6 +801,8 @@ static int load_super_ddf(struct supertype *st, int fd,
return 1;
}
+ free_super_ddf(st);
+
if (posix_memalign((void**)&super, 512, sizeof(*super))!= 0) {
fprintf(stderr, Name ": malloc of %zu failed.\n",
sizeof(*super));