From a95c7bc1320904a3339e9e7cf46bc1b03724db44 Mon Sep 17 00:00:00 2001 From: "Thordur I. Bjornsson" Date: Thu, 6 Jan 2011 17:32:43 +0000 Subject: init and destory the bufq in the ioctl handler, as the softc is zero'ed when the vnd is unconfigured; otherwise we blow up when configuring a vnd the second time since the bufq structure is kaputt. found by and OK krw@ --- sys/dev/vnd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sys') diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c index e8b0a7cf78e..0a18e297a8b 100644 --- a/sys/dev/vnd.c +++ b/sys/dev/vnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vnd.c,v 1.105 2011/01/05 15:35:43 thib Exp $ */ +/* $OpenBSD: vnd.c,v 1.106 2011/01/06 17:32:42 thib Exp $ */ /* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */ /* @@ -210,7 +210,6 @@ vndattach(int num) vnd_softc = (struct vnd_softc *)mem; for (i = 0; i < num; i++) { rw_init(&vnd_softc[i].sc_rwlock, "vndlock"); - bufq_init(&vnd_softc[i].sc_bufq, BUFQ_DEFAULT); } numvnd = num; @@ -872,6 +871,7 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) /* Attach the disk. */ vnd->sc_dk.dk_name = vnd->sc_dk_name; disk_attach(&vnd->sc_dev, &vnd->sc_dk); + bufq_init(&vnd->sc_bufq, BUFQ_DEFAULT); vndunlock(vnd); @@ -908,6 +908,7 @@ vndioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) } /* Detach the disk. */ + bufq_destroy(&vnd->sc_bufq); disk_detach(&vnd->sc_dk); /* This must be atomic. */ -- cgit v1.2.3