Hans de Goede: mdmon: fix freeing unallocated memory
Martin F. Krafft
madduck at alioth.debian.org
Tue Oct 27 19:21:48 UTC 2009
Module: mdadm
Branch: upstream
Commit: f5df5d69a78b03b7c843e3642725381fc9c76b95
URL: http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=f5df5d69a78b03b7c843e3642725381fc9c76b95
Author: Hans de Goede <hdegoede at redhat.com>
Date: Thu Sep 24 06:52:06 2009 -0700
mdmon: fix freeing unallocated memory
mdmon was creating a supertype struct with malloc, and thus not
necessarily getting zero-d memory.
This was causing it to segfault when called like this from the initrd:
/sbin/mdmon /proc/mdstat /sysroot
The problem was that load_super_imsm would get called on the non-zero'd
super struct, whcih in turn calls free_super_imsm, which checks st->sb,
which should be zero but isn't and then starts freeing bogus memory.
Signed-off-by: Dan Williams <dan.j.williams at intel.com>
---
mdmon.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/mdmon.c b/mdmon.c
index 37f97af..31994d8 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -395,7 +395,7 @@ int mdmon(char *devname, int devnum, int scan, char *switchroot)
} else
pfd[0] = pfd[1] = -1;
- container = malloc(sizeof(*container));
+ container = calloc(1, sizeof(*container));
container->devnum = devnum;
container->devname = devname;
container->arrays = NULL;
More information about the pkg-mdadm-commits
mailing list