From ab5fff1edaeca8ceb09119f2e5cb8016ce42acbc Mon Sep 17 00:00:00 2001 From: mycroft Date: Mon, 8 Sep 2003 23:43:35 +0000 Subject: [PATCH] Fix an error path where we might scsipi_prevent() on a non-removable device. --- sys/dev/scsipi/sd.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/dev/scsipi/sd.c b/sys/dev/scsipi/sd.c index e982bb0c28b9..37fa47cb3f9b 100644 --- a/sys/dev/scsipi/sd.c +++ b/sys/dev/scsipi/sd.c @@ -1,4 +1,4 @@ -/* $NetBSD: sd.c,v 1.204 2003/09/08 18:51:38 mycroft Exp $ */ +/* $NetBSD: sd.c,v 1.205 2003/09/08 23:43:35 mycroft Exp $ */ /*- * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.204 2003/09/08 18:51:38 mycroft Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.205 2003/09/08 23:43:35 mycroft Exp $"); #include "opt_scsi.h" #include "opt_bufq.h" @@ -510,8 +510,10 @@ bad2: bad: if (sd->sc_dk.dk_openmask == 0) { - scsipi_prevent(periph, PR_ALLOW, - XS_CTL_IGNORE_ILLEGAL_REQUEST | XS_CTL_IGNORE_MEDIA_CHANGE); + if (periph->periph_flags & PERIPH_REMOVABLE) + scsipi_prevent(periph, PR_ALLOW, + XS_CTL_IGNORE_ILLEGAL_REQUEST | + XS_CTL_IGNORE_MEDIA_CHANGE); periph->periph_flags &= ~PERIPH_OPEN; } @@ -573,11 +575,10 @@ sdclose(dev, flag, fmt, p) scsipi_wait_drain(periph); - if (periph->periph_flags & PERIPH_REMOVABLE) { + if (periph->periph_flags & PERIPH_REMOVABLE) scsipi_prevent(periph, PR_ALLOW, XS_CTL_IGNORE_ILLEGAL_REQUEST | XS_CTL_IGNORE_NOT_READY); - } periph->periph_flags &= ~PERIPH_OPEN; scsipi_wait_drain(periph);