From 1cb18ce25d36afad700770780a783fdcd50bb8b6 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Sat, 20 Dec 1997 23:03:49 +0000 Subject: [PATCH] Protect against a null pointer dereferencation in the case of an unknown drive. Such a drive will be configured by worm(4) nevertheless (albeit with a warning), but cannot be opened except of the SCSI control device (so scsi(8) or cdrecord will continue to work). --- sys/scsi/worm.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/scsi/worm.c b/sys/scsi/worm.c index bff501404f8..b0117d51be3 100644 --- a/sys/scsi/worm.c +++ b/sys/scsi/worm.c @@ -43,7 +43,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: worm.c,v 1.47 1997/10/27 21:09:27 jmz Exp $ + * $Id: worm.c,v 1.48 1997/12/02 21:07:07 phk Exp $ */ #include "opt_bounce.h" @@ -264,6 +264,9 @@ wormattach(struct scsi_link *sc_link) #endif struct scsi_data *worm = sc_link->sd; + if (sc_link->devmodes == 0) + printf(", warning: unknown drive type", unit); + bufq_init(&worm->buf_queue); #ifdef DEVFS @@ -494,6 +497,14 @@ worm_open(dev_t dev, int flags, int fmt, struct proc *p, if (sc_link->flags & SDEV_OPEN) return EBUSY; + /* + * Unknown drive type: only the control device can be opened + * in this case, so scsi(8) and things like cdrecord will + * work. + */ + if (sc_link->devmodes == 0) + return ENXIO; + /* * Check that it is still responding and ok. * if the media has been changed this will result in a