aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndre Noll <maan@systemlinux.org>2008-11-06 03:41:24 -0500
committerNeilBrown <neilb@suse.de>2008-11-06 03:41:24 -0500
commitf1cd14ae52985634d0389e934eba25b5ecf24565 (patch)
tree131e1fedd27d63d30896233d695594508bdbd04f /drivers
parenta53a6c85756339f82ff19e001e90cfba2d6299a8 (diff)
md: linear: Fix a division by zero bug for very small arrays.
We currently oops with a divide error on starting a linear software raid array consisting of at least two very small (< 500K) devices. The bug is caused by the calculation of the hash table size which tries to compute sector_div(sz, base) with "base" being zero due to the small size of the component devices of the array. Fix this by requiring the hash spacing to be at least one which implies that also "base" is non-zero. This bug has existed since about 2.6.14. Cc: stable@kernel.org Signed-off-by: Andre Noll <maan@systemlinux.org> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/linear.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 190147c79e79..3b90c5c924ec 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -148,6 +148,8 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
148 148
149 min_sectors = conf->array_sectors; 149 min_sectors = conf->array_sectors;
150 sector_div(min_sectors, PAGE_SIZE/sizeof(struct dev_info *)); 150 sector_div(min_sectors, PAGE_SIZE/sizeof(struct dev_info *));
151 if (min_sectors == 0)
152 min_sectors = 1;
151 153
152 /* min_sectors is the minimum spacing that will fit the hash 154 /* min_sectors is the minimum spacing that will fit the hash
153 * table in one PAGE. This may be much smaller than needed. 155 * table in one PAGE. This may be much smaller than needed.