summaryrefslogtreecommitdiffstats
path: root/Incremental.c
diff options
context:
space:
mode:
authorDoug Ledford <dledford@redhat.com>2008-10-29 15:05:36 -0400
committerNeilBrown <neilb@suse.de>2008-10-30 08:53:02 +1100
commit43aaf431f66270080368d4b33378bd3dc0fa1c96 (patch)
treee3c2fb5f255e13aec20da27a4623a36d9b927bb3 /Incremental.c
parentd7ee65c960fa8a6886df7416307f57545ddc4460 (diff)
downloadmdadm-43aaf431f66270080368d4b33378bd3dc0fa1c96.tar.gz
mdadm-43aaf431f66270080368d4b33378bd3dc0fa1c96.tar.xz
mdadm-43aaf431f66270080368d4b33378bd3dc0fa1c96.zip
Fix NULL pointer oops
RAID10 is the only raid level that uses the avail char array pointer during the enough() operation, so it was the only one that saw this. The code in incremental assumes unconditionally that count_active will allocate the avail char array, that it might be used by enough, and that it will need to be freed afterward. Once you make count_active actually do that, then the oops goes away. Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Incremental.c')
-rw-r--r--Incremental.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Incremental.c b/Incremental.c
index 0fb9afd..9c6524f 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -543,12 +543,18 @@ static int count_active(struct supertype *st, int mdfd, char **availp,
if (ok != 0)
continue;
st->ss->getinfo_super(st, &info);
+ if (!avail) {
+ avail = malloc(info.array.raid_disks);
+ if (!avail) {
+ fprintf(stderr, Name ": out of memory.\n");
+ exit(1);
+ }
+ memset(avail, 0, info.array.raid_disks);
+ *availp = avail;
+ }
+
if (info.disk.state & (1<<MD_DISK_SYNC))
{
- if (avail == NULL) {
- avail = malloc(info.array.raid_disks);
- memset(avail, 0, info.array.raid_disks);
- }
if (cnt == 0) {
cnt++;
max_events = info.events;