diff options
author | Matthew Dempsky <matthew@cvs.openbsd.org> | 2011-07-06 04:49:37 +0000 |
---|---|---|
committer | Matthew Dempsky <matthew@cvs.openbsd.org> | 2011-07-06 04:49:37 +0000 |
commit | 51c6c9b181971ccd9a6d6f7f9dd1fa5dc8df1c23 (patch) | |
tree | 9e6859366146d5377f6e62a5adfeca45f358d3ad /sys/arch/octeon/dev/octcf.c | |
parent | 9f81aca0122f901a2f924a0d3d759a2d37d682de (diff) |
Eliminate redundant buf validation checks in xxstrategy() methods now
that they're implemented consistently in bounds_check_with_label().
Also, per krw's request, change bounds_check_with_label() to return 0
if the checks succeed, and change the drivers to test == -1 instead of
<= 0. (Man page update to follow; intentionally omitting
arch/vax/mba/hp.c from this commit because it doesn't even build
currently and miod@ promises to kill it soon.)
ok krw@
Diffstat (limited to 'sys/arch/octeon/dev/octcf.c')
-rw-r--r-- | sys/arch/octeon/dev/octcf.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/sys/arch/octeon/dev/octcf.c b/sys/arch/octeon/dev/octcf.c index a6879e15e0f..ccba97d1063 100644 --- a/sys/arch/octeon/dev/octcf.c +++ b/sys/arch/octeon/dev/octcf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: octcf.c,v 1.6 2011/06/19 04:55:34 deraadt Exp $ */ +/* $OpenBSD: octcf.c,v 1.7 2011/07/06 04:49:35 matthew Exp $ */ /* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */ /* @@ -302,27 +302,22 @@ octcfstrategy(struct buf *bp) } OCTCFDEBUG_PRINT(("octcfstrategy (%s)\n", wd->sc_dev.dv_xname), DEBUG_XFERS); - /* Valid request? */ - if (bp->b_blkno < 0 || - (bp->b_bcount % wd->sc_dk.dk_label->d_secsize) != 0 || - (bp->b_bcount / wd->sc_dk.dk_label->d_secsize) >= (1 << NBBY)) { - bp->b_error = EINVAL; - goto bad; - } /* If device invalidated (e.g. media change, door open), error. */ if ((wd->sc_flags & OCTCFF_LOADED) == 0) { bp->b_error = EIO; goto bad; } - /* If it's a null transfer, return immediately. */ - if (bp->b_bcount == 0) - goto done; - /* - * Do bounds checking, adjust transfer. if error, process. - * If end of partition, just return. - */ - if (bounds_check_with_label(bp, wd->sc_dk.dk_label) <= 0) + + /* Validate the request. */ + if (bounds_check_with_label(bp, wd->sc_dk.dk_label) == -1) goto done; + + /* Check that the number of sectors can fit in a byte. */ + if ((bp->b_bcount / wd->sc_dk.dk_label->d_secsize) >= (1 << NBBY)) { + bp->b_error = EINVAL; + goto bad; + } + /* Queue transfer on drive, activate drive and controller if idle. */ s = splbio(); disksort(&wd->sc_q, bp); @@ -330,11 +325,11 @@ octcfstrategy(struct buf *bp) splx(s); device_unref(&wd->sc_dev); return; -bad: + + bad: bp->b_flags |= B_ERROR; -done: - /* Toss transfer; we're done early. */ bp->b_resid = bp->b_bcount; + done: s = splbio(); biodone(bp); splx(s); |