From fec31ce43e3f20a77966065864467e0eb6df2a4a Mon Sep 17 00:00:00 2001 From: bouyer Date: Wed, 19 Nov 2008 18:38:36 +0000 Subject: [PATCH] Check that vnd is not NULL before using it, return ENXIO if it is. Avoids a panic when vnconfig -uF is used on a busy vnd. --- sys/dev/vnd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c index 8ecf9b44a82a..5b45adcd7d22 100644 --- a/sys/dev/vnd.c +++ b/sys/dev/vnd.c @@ -1,4 +1,4 @@ -/* $NetBSD: vnd.c,v 1.188 2008/11/12 12:36:11 ad Exp $ */ +/* $NetBSD: vnd.c,v 1.189 2008/11/19 18:38:36 bouyer Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. @@ -130,7 +130,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.188 2008/11/12 12:36:11 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.189 2008/11/19 18:38:36 bouyer Exp $"); #if defined(_KERNEL_OPT) #include "fs_nfs.h" @@ -448,10 +448,16 @@ vndstrategy(struct buf *bp) int unit = vndunit(bp->b_dev); struct vnd_softc *vnd = device_lookup_private(&vnd_cd, unit); - struct disklabel *lp = vnd->sc_dkdev.dk_label; + struct disklabel *lp; daddr_t blkno; int s = splbio(); + if (vnd == NULL) { + bp->b_error = ENXIO; + goto done; + } + lp = vnd->sc_dkdev.dk_label; + if ((vnd->sc_flags & VNF_INITED) == 0) { bp->b_error = ENXIO; goto done;