diff options
| author | 2011-07-06 04:49:35 +0000 | |
|---|---|---|
| committer | 2011-07-06 04:49:35 +0000 | |
| commit | d1e5b14ce27677c18027bd4cc75633df5e5acccf (patch) | |
| tree | c7045e866fdf213f4e9aa471ee8f12213caaed7a /sys/dev/flash.c | |
| parent | Return the correct error for fchdir(not_file_or_dir) (diff) | |
| download | wireguard-openbsd-d1e5b14ce27677c18027bd4cc75633df5e5acccf.tar.xz wireguard-openbsd-d1e5b14ce27677c18027bd4cc75633df5e5acccf.zip | |
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/dev/flash.c')
| -rw-r--r-- | sys/dev/flash.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/sys/dev/flash.c b/sys/dev/flash.c index 27215ce1c14..8f5dd8dd48f 100644 --- a/sys/dev/flash.c +++ b/sys/dev/flash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flash.c,v 1.23 2011/06/19 04:55:33 deraadt Exp $ */ +/* $OpenBSD: flash.c,v 1.24 2011/07/06 04:49:36 matthew Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@openbsd.org> @@ -784,12 +784,6 @@ flashstrategy(struct buf *bp) goto bad; } - /* Transfer only a multiple of the flash page size. */ - if ((bp->b_bcount % sc->sc_flashdev->pagesize) != 0) { - bp->b_error = EINVAL; - goto bad; - } - /* If the device has been invalidated, error out. */ if ((sc->sc_flags & FDK_LOADED) == 0) { bp->b_error = EIO; @@ -797,15 +791,14 @@ flashstrategy(struct buf *bp) } /* Translate logical block numbers to physical. */ - if (flashsafe(bp->b_dev) && flashsafestrategy(sc, bp) <= 0) - goto done; - - /* Return immediately if it is a null transfer. */ - if (bp->b_bcount == 0) + if (flashsafe(bp->b_dev) && flashsafestrategy(sc, bp) <= 0) { + if (bp->b_flags & B_ERROR) + bp->b_resid = bp->b_bcount; goto done; + } - /* Do bounds checking on partitions. */ - if (bounds_check_with_label(bp, sc->sc_dk.dk_label) <= 0) + /* Validate the request. */ + if (bounds_check_with_label(bp, sc->sc_dk.dk_label) == -1) goto done; /* Queue the transfer. */ @@ -816,11 +809,10 @@ flashstrategy(struct buf *bp) device_unref(&sc->sc_dev); return; -bad: + bad: bp->b_flags |= B_ERROR; -done: - if ((bp->b_flags & B_ERROR) != 0) - bp->b_resid = bp->b_bcount; + bp->b_resid = bp->b_bcount; + done: s = splbio(); biodone(bp); splx(s); |
