summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2015-07-26 14:01:08 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2015-07-26 14:01:08 +0000
commitbd3a3981463b99c7d34f574c1b6b445eb6a79952 (patch)
treea68a976e7858dee59f4ec5ee99b5c50f6ef8b4ae
parent9055008857c17ccb688091488fbfd6b1d6706288 (diff)
Always initialize the b_error field and B_ERROR flag before using
a buf. Otherwise stale data might cause a successful I/O to be seen as a failed I/O. ok tedu@
-rw-r--r--sys/kern/subr_disk.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 3b3e37610ac..08ce9348005 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.184 2015/07/23 18:02:59 krw Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.185 2015/07/26 14:01:07 krw Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -532,7 +532,8 @@ notfat:
offset = DL_BLKOFFSET(lp, DL_SECTOBLK(lp, dospartoff) +
DOS_LABELSECTOR);
bp->b_bcount = lp->d_secsize;
- CLR(bp->b_flags, B_READ | B_WRITE | B_DONE);
+ bp->b_error = 0; /* B_ERROR and b_error may have stale data. */
+ CLR(bp->b_flags, B_READ | B_WRITE | B_DONE | B_ERROR);
SET(bp->b_flags, B_BUSY | B_READ | B_RAW);
(*strat)(bp);
if (biowait(bp))
@@ -855,7 +856,8 @@ readgptlabel(struct buf *bp, void (*strat)(struct buf *),
DL_BLKSPERSEC(lp);
offset = DL_BLKOFFSET(lp, gptpartoff + DOS_LABELSECTOR);
bp->b_bcount = lp->d_secsize;
- CLR(bp->b_flags, B_READ | B_WRITE | B_DONE);
+ bp->b_error = 0; /* B_ERROR and b_error may have stale data. */
+ CLR(bp->b_flags, B_READ | B_WRITE | B_DONE | B_ERROR);
SET(bp->b_flags, B_BUSY | B_READ | B_RAW);
(*strat)(bp);
if (biowait(bp))