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).
This commit is contained in:
Joerg Wunsch 1997-12-20 23:03:49 +00:00
parent 675c4fdb61
commit 1cb18ce25d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=31908

View File

@ -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