Commit ccd3a853 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] md - Zero out some kmalloced space in md driver

This should fix most (all??) of the recently reported problems with MD:

Recent changes to md malloced some data structures differently and
didn't zero out those data structures, where the old code had zeroed it
out.

This adds the relevant memsets.
parent 3935761c
......@@ -93,7 +93,7 @@ static int linear_run (mddev_t *mddev)
GFP_KERNEL);
if (!conf)
goto out;
memset(conf, 0, sizeof(*conf));
memset(conf, 0, sizeof(*conf) + mddev->raid_disks*sizeof(dev_info_t));
mddev->private = conf;
/*
......
......@@ -397,6 +397,7 @@ static int multipath_run (mddev_t *mddev)
mdidx(mddev));
goto out_free_conf;
}
memset(conf->multipaths, 0, sizeof(struct multipath_info)*mddev->raid_disks);
conf->working_disks = 0;
ITERATE_RDEV(mddev,rdev,tmp) {
......
......@@ -90,6 +90,9 @@ static int create_strip_zones (mddev_t *mddev)
memset(conf->strip_zone, 0,sizeof(struct strip_zone)*
conf->nr_strip_zones);
memset(conf->devlist, 0,
sizeof(mdk_rdev_t*) * conf->nr_strip_zones * mddev->raid_disks);
/* The first zone must contain all devices, so here we check that
* there is a proper alignment of slots to devices and find them all
*/
......
......@@ -47,7 +47,7 @@ static void * r1bio_pool_alloc(int gfp_flags, void *data)
r1_bio = kmalloc(sizeof(r1bio_t) + sizeof(struct bio*)*mddev->raid_disks,
gfp_flags);
if (r1_bio)
memset(r1_bio, 0, sizeof(*r1_bio));
memset(r1_bio, 0, sizeof(*r1_bio) + sizeof(struct bio*)*mddev->raid_disks);
return r1_bio;
}
......@@ -1057,6 +1057,7 @@ static int run(mddev_t *mddev)
mdidx(mddev));
goto out_free_conf;
}
memset(conf->mirrors, 0, sizeof(struct mirror_info)*mddev->raid_disks);
conf->r1bio_pool = mempool_create(NR_RAID1_BIOS, r1bio_pool_alloc,
r1bio_pool_free, mddev);
......
......@@ -1458,7 +1458,7 @@ static int run (mddev_t *mddev)
GFP_KERNEL);
if ((conf = mddev->private) == NULL)
goto abort;
memset (conf, 0, sizeof (*conf));
memset (conf, 0, sizeof (*conf) + mddev->raid_disks * sizeof(struct disk_info) );
conf->mddev = mddev;
if ((conf->stripe_hashtbl = (struct stripe_head **) __get_free_pages(GFP_ATOMIC, HASH_PAGES_ORDER)) == NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment