summaryrefslogtreecommitdiff
path: root/sys/arch/sparc/dev/presto.c
diff options
context:
space:
mode:
authorMatthew Dempsky <matthew@cvs.openbsd.org>2011-07-06 04:49:37 +0000
committerMatthew Dempsky <matthew@cvs.openbsd.org>2011-07-06 04:49:37 +0000
commit51c6c9b181971ccd9a6d6f7f9dd1fa5dc8df1c23 (patch)
tree9e6859366146d5377f6e62a5adfeca45f358d3ad /sys/arch/sparc/dev/presto.c
parent9f81aca0122f901a2f924a0d3d759a2d37d682de (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/sparc/dev/presto.c')
-rw-r--r--sys/arch/sparc/dev/presto.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/sys/arch/sparc/dev/presto.c b/sys/arch/sparc/dev/presto.c
index f9d05429d4c..b242ce3fd97 100644
--- a/sys/arch/sparc/dev/presto.c
+++ b/sys/arch/sparc/dev/presto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: presto.c,v 1.21 2011/06/03 21:14:11 matthew Exp $ */
+/* $OpenBSD: presto.c,v 1.22 2011/07/06 04:49:35 matthew Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
@@ -280,15 +280,14 @@ prestostrategy(struct buf *bp)
sc = (struct presto_softc *)device_lookup(&presto_cd, unit);
/* Sort rogue requests out */
- if (sc == NULL || bp->b_blkno < 0 ||
- (bp->b_bcount % sc->sc_dk.dk_label->d_secsize) != 0) {
+ if (sc == NULL) {
bp->b_error = EINVAL;
goto bad;
}
- /* Do not write on "no trespassing" areas... */
- if (bounds_check_with_label(bp, sc->sc_dk.dk_label) <= 0)
- goto bad;
+ /* Validate the request. */
+ if (bounds_check_with_label(bp, sc->sc_dk.dk_label) == -1)
+ goto done;
/* Bound the request size, then move data between buf and nvram */
bp->b_resid = bp->b_bcount;
@@ -303,11 +302,10 @@ prestostrategy(struct buf *bp)
bp->b_resid -= count;
goto done;
-bad:
+ bad:
bp->b_flags |= B_ERROR;
bp->b_resid = bp->b_bcount;
-
-done:
+ done:
s = splbio();
biodone(bp);
splx(s);