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.
This commit is contained in:
bouyer 2008-11-19 18:38:36 +00:00
parent df7a9dd3a8
commit fec31ce43e
1 changed files with 9 additions and 3 deletions

View File

@ -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 <sys/cdefs.h>
__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;