summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgrog <grog@FreeBSD.org>1999-04-09 01:20:22 +0000
committergrog <grog@FreeBSD.org>1999-04-09 01:20:22 +0000
commit2dbfcc3870c83de97f28288eb29f4274983dcd28 (patch)
treeb77296cb73c5185f59a352e341bd57f5f30676de
parentb08fc2420a9eae143fe6d629ec5a57c3393be254 (diff)
downloadFreeBSD-src-2dbfcc3870c83de97f28288eb29f4274983dcd28.zip
FreeBSD-src-2dbfcc3870c83de97f28288eb29f4274983dcd28.tar.gz
update_plex_config: Eliminate a potential divide-by-zero.
Tripped-over-by: Karl Pielorz <kpielorz@tdx.co.uk>
-rw-r--r--sys/dev/vinum/vinumconfig.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/sys/dev/vinum/vinumconfig.c b/sys/dev/vinum/vinumconfig.c
index 7fc6520..67cd1c6 100644
--- a/sys/dev/vinum/vinumconfig.c
+++ b/sys/dev/vinum/vinumconfig.c
@@ -1826,19 +1826,21 @@ update_plex_config(int plexno, int diskconfig)
* the stripe size. If not, trim off the end
* of each subdisk and return it to the drive.
*/
- remainder = (int) (plex->length % ((u_int64_t) plex->stripesize * data_sds)); /* are we exact? */
- if (remainder) { /* no */
- log(LOG_INFO, "vinum: removing %d blocks of partial stripe at the end of %s\n",
- remainder,
- plex->name);
- plex->length -= remainder; /* shorten the plex */
- remainder /= data_sds; /* spread the remainder amongst the sds */
- for (sdno = 0; sdno < plex->subdisks; sdno++) {
- sd = &SD[plex->sdnos[sdno]]; /* point to the subdisk */
- return_drive_space(sd->driveno, /* return the space */
- sd->driveoffset + sd->sectors - remainder,
- remainder);
- sd->sectors -= remainder; /* and shorten it */
+ if (plex->length > 0) {
+ remainder = (int) (plex->length % ((u_int64_t) plex->stripesize * data_sds)); /* are we exact? */
+ if (remainder) { /* no */
+ log(LOG_INFO, "vinum: removing %d blocks of partial stripe at the end of %s\n",
+ remainder,
+ plex->name);
+ plex->length -= remainder; /* shorten the plex */
+ remainder /= data_sds; /* spread the remainder amongst the sds */
+ for (sdno = 0; sdno < plex->subdisks; sdno++) {
+ sd = &SD[plex->sdnos[sdno]]; /* point to the subdisk */
+ return_drive_space(sd->driveno, /* return the space */
+ sd->driveoffset + sd->sectors - remainder,
+ remainder);
+ sd->sectors -= remainder; /* and shorten it */
+ }
}
}
}
OpenPOWER on IntegriCloud