Skip to content

Commit

Permalink
md: linear: Fix a division by zero bug for very small arrays.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andre Noll authored and NeilBrown committed Nov 6, 2008
1 parent a53a6c8 commit f1cd14a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/md/linear.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit f1cd14a

Please sign in to comment.