From: krw Date: Sun, 27 Feb 2022 02:27:55 +0000 (+0000) Subject: SC_DEBUG() requires an initialized scsi_link. Shuffle X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=dd2bb77956f6643e4de5609f1ab8f5ec99fc81de;p=openbsd SC_DEBUG() requires an initialized scsi_link. Shuffle code to make it so. Pointed out by clang when prodded with SCSIDEBUG. --- diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index bb19ee0cd92..7e5570fb9b2 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.330 2021/10/24 16:57:30 mpi Exp $ */ +/* $OpenBSD: sd.c,v 1.331 2022/02/27 02:27:55 krw Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -315,10 +315,6 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p) unit = DISKUNIT(dev); part = DISKPART(dev); - SC_DEBUG(link, SDEV_DB1, - ("sdopen: dev=0x%x (unit %d (of %d), partition %d)\n", dev, unit, - sd_cd.cd_ndevs, part)); - rawopen = (part == RAW_PART) && (fmt == S_IFCHR); sc = sdlookup(unit); @@ -330,6 +326,10 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p) } link = sc->sc_link; + SC_DEBUG(link, SDEV_DB1, + ("sdopen: dev=0x%x (unit %d (of %d), partition %d)\n", dev, unit, + sd_cd.cd_ndevs, part)); + if (ISSET(flag, FWRITE) && ISSET(link->flags, SDEV_READONLY)) { device_unref(&sc->sc_dev); return EACCES; diff --git a/sys/scsi/st.c b/sys/scsi/st.c index 7cee3848fa9..34ee76916f6 100644 --- a/sys/scsi/st.c +++ b/sys/scsi/st.c @@ -1,4 +1,4 @@ -/* $OpenBSD: st.c,v 1.188 2022/01/11 23:10:11 jsg Exp $ */ +/* $OpenBSD: st.c,v 1.189 2022/02/27 02:27:55 krw Exp $ */ /* $NetBSD: st.c,v 1.71 1997/02/21 23:03:49 thorpej Exp $ */ /* @@ -360,8 +360,8 @@ stopen(dev_t dev, int flags, int fmt, struct proc *p) if (st == NULL) return ENXIO; if (ISSET(st->flags, ST_DYING)) { - error = ENXIO; - goto done; + device_unref(&st->sc_dev); + return ENXIO; } link = st->sc_link;