diff options
author | mav <mav@FreeBSD.org> | 2015-01-26 15:47:08 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2015-01-26 15:47:08 +0000 |
commit | bd34e367bbf0be832245c751c973aa915890dcfd (patch) | |
tree | 10f072fbb2074ea634cb3b7fbc78146f4d086ce3 | |
parent | ee153e65b07952390f8cea3cfd0bb4826636da1e (diff) | |
download | FreeBSD-src-bd34e367bbf0be832245c751c973aa915890dcfd.zip FreeBSD-src-bd34e367bbf0be832245c751c973aa915890dcfd.tar.gz |
Fix several potential overflows in UNMAP code.
MFC after: 1 week
-rw-r--r-- | sys/cam/scsi/scsi_da.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 2d09d57..a65d2dc 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -1910,18 +1910,18 @@ dadeletemaxsize(struct da_softc *softc, da_delete_methods delete_method) sectors = (off_t)ATA_DSM_RANGE_MAX * softc->trim_max_ranges; break; case DA_DELETE_WS16: - sectors = (off_t)min(softc->ws_max_blks, WS16_MAX_BLKS); + sectors = omin(softc->ws_max_blks, WS16_MAX_BLKS); break; case DA_DELETE_ZERO: case DA_DELETE_WS10: - sectors = (off_t)min(softc->ws_max_blks, WS10_MAX_BLKS); + sectors = omin(softc->ws_max_blks, WS10_MAX_BLKS); break; default: return 0; } return (off_t)softc->params.secsize * - min(sectors, (off_t)softc->params.sectors); + omin(sectors, softc->params.sectors); } static void @@ -2684,7 +2684,7 @@ da_delete_trim(struct cam_periph *periph, union ccb *ccb, struct bio *bp) /* Try to extend the previous range. */ if (lba == lastlba) { - c = min(count, ATA_DSM_RANGE_MAX - lastcount); + c = omin(count, ATA_DSM_RANGE_MAX - lastcount); lastcount += c; off = (ranges - 1) * 8; buf[off + 6] = lastcount & 0xff; @@ -2694,7 +2694,7 @@ da_delete_trim(struct cam_periph *periph, union ccb *ccb, struct bio *bp) } while (count > 0) { - c = min(count, ATA_DSM_RANGE_MAX); + c = omin(count, ATA_DSM_RANGE_MAX); off = ranges * 8; buf[off + 0] = lba & 0xff; @@ -2770,7 +2770,7 @@ da_delete_ws(struct cam_periph *periph, union ccb *ccb, struct bio *bp) "%s issuing short delete %ld > %ld\n", da_delete_method_desc[softc->delete_method], count, ws_max_blks); - count = min(count, ws_max_blks); + count = omin(count, ws_max_blks); break; } bp1 = bioq_first(&softc->delete_queue); |