summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthew <matthew@openbsd.org>2011-06-07 15:42:29 +0000
committermatthew <matthew@openbsd.org>2011-06-07 15:42:29 +0000
commit72b460fad81b7c584802da48d7e11c6667b43482 (patch)
treea7f54ca70df2f10c29c0d9f06ecc7145ef9a359c
parent- add extensive testing for various versioned suffix combinations (diff)
downloadwireguard-openbsd-72b460fad81b7c584802da48d7e11c6667b43482.tar.xz
wireguard-openbsd-72b460fad81b7c584802da48d7e11c6667b43482.zip
Fix a device reference leak in st{read,write}() by making them work
like {cd,sd}{read,write}(). ok krw@, dlg@
-rw-r--r--sys/scsi/st.c26
1 files changed, 2 insertions, 24 deletions
diff --git a/sys/scsi/st.c b/sys/scsi/st.c
index d22f35e9dba..c06359d497c 100644
--- a/sys/scsi/st.c
+++ b/sys/scsi/st.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: st.c,v 1.119 2011/03/31 18:42:48 jasper Exp $ */
+/* $OpenBSD: st.c,v 1.120 2011/06/07 15:42:29 matthew Exp $ */
/* $NetBSD: st.c,v 1.71 1997/02/21 23:03:49 thorpej Exp $ */
/*
@@ -1111,7 +1111,7 @@ stminphys(struct buf *bp)
st = stlookup(STUNIT(bp->b_dev));
if (st == NULL)
- return; /* can't happen */
+ return;
(*st->sc_link->adapter->scsi_minphys)(bp, st->sc_link);
@@ -1121,34 +1121,12 @@ stminphys(struct buf *bp)
int
stread(dev_t dev, struct uio *uio, int iomode)
{
- struct st_softc *st;
-
- st = stlookup(STUNIT(dev));
- if (st == NULL)
- return (ENXIO);
-
- if (st->flags & ST_DYING) {
- device_unref(&st->sc_dev);
- return (ENXIO);
- }
-
return (physio(ststrategy, dev, B_READ, stminphys, uio));
}
int
stwrite(dev_t dev, struct uio *uio, int iomode)
{
- struct st_softc *st;
-
- st = stlookup(STUNIT(dev));
- if (st == NULL)
- return (ENXIO);
-
- if (st->flags & ST_DYING) {
- device_unref(&st->sc_dev);
- return (ENXIO);
- }
-
return (physio(ststrategy, dev, B_WRITE, stminphys, uio));
}