|author||Andre Noll <email@example.com>||2008-11-06 19:41:24 +1100|
|committer||NeilBrown <firstname.lastname@example.org>||2008-11-06 19:41:24 +1100|
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: email@example.com Signed-off-by: Andre Noll <firstname.lastname@example.org> Signed-off-by: NeilBrown <email@example.com>
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 190147c79e7..3b90c5c924e 100644
@@ -148,6 +148,8 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
min_sectors = conf->array_sectors;
sector_div(min_sectors, PAGE_SIZE/sizeof(struct dev_info *));
+ if (min_sectors == 0)
+ min_sectors = 1;
/* min_sectors is the minimum spacing that will fit the hash
* table in one PAGE. This may be much smaller than needed.