diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2005-05-03 00:29:17 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2005-05-03 00:29:17 +0000 |
commit | 2a53e029459c57b7b8a7bca2ed4c244919e74c39 (patch) | |
tree | 03cf38159e3ca93c670db493df3256fab97f1b3c /sys/scsi/sd.c | |
parent | 116ebc7eb48e17bf2aff3d692766e0496aaa2a01 (diff) |
sdstrategy() shouldn't use values in disklabel until SDEV_MEDIA_LOADED
is checked. Fixes crash during boot when a device has no media
loaded. e.g. a usb card reader with empty slots. From NetBSD. Problem
was introduced by last commit to allow RAW_PART+S_IFCHAR opens to
always succeed.
ok millert@ marco@
Diffstat (limited to 'sys/scsi/sd.c')
-rw-r--r-- | sys/scsi/sd.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index 33e41e1c884..ddd0e38f43d 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.76 2005/05/01 19:29:17 krw Exp $ */ +/* $OpenBSD: sd.c,v 1.77 2005/05/03 00:29:16 krw Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -549,13 +549,6 @@ sdstrategy(bp) SC_DEBUG(sd->sc_link, SDEV_DB2, ("sdstrategy: %ld bytes @ blk %d\n", bp->b_bcount, bp->b_blkno)); /* - * The transfer must be a whole number of blocks. - */ - if ((bp->b_bcount % sd->sc_dk.dk_label->d_secsize) != 0) { - bp->b_error = EINVAL; - goto bad; - } - /* * If the device has been made invalid, error out */ if ((sd->sc_link->flags & SDEV_MEDIA_LOADED) == 0) { @@ -572,6 +565,13 @@ sdstrategy(bp) goto done; /* + * The transfer must be a whole number of blocks. + */ + if ((bp->b_bcount % sd->sc_dk.dk_label->d_secsize) != 0) { + bp->b_error = EINVAL; + goto bad; + } + /* * Do bounds checking, adjust transfer. if error, process. * If end of partition, just return. */ |