diff options
author | weongyo <weongyo@FreeBSD.org> | 2010-11-23 20:23:25 +0000 |
---|---|---|
committer | weongyo <weongyo@FreeBSD.org> | 2010-11-23 20:23:25 +0000 |
commit | fa008bbea792973410d0c07f5586d3e2a02f8845 (patch) | |
tree | 2dbdafd06ed612114ab43bbc6bdd713f40ba4873 /sys/dev/usb/usb_pf.c | |
parent | 762cf185a2b902bb488a94812e069a0566a76795 (diff) | |
download | FreeBSD-src-fa008bbea792973410d0c07f5586d3e2a02f8845.zip FreeBSD-src-fa008bbea792973410d0c07f5586d3e2a02f8845.tar.gz |
Fixes a kernel crash when usb module is reloaded after unload that it
didn't destroy the cdev properly.
Pointy hat to: me
Reported by: Brandon Gooch <jamesbrandongooch at gmail dot com>, jkim
Diffstat (limited to 'sys/dev/usb/usb_pf.c')
-rw-r--r-- | sys/dev/usb/usb_pf.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/dev/usb/usb_pf.c b/sys/dev/usb/usb_pf.c index 3f5f204..0da4d88 100644 --- a/sys/dev/usb/usb_pf.c +++ b/sys/dev/usb/usb_pf.c @@ -141,6 +141,7 @@ static struct cdevsw usbpf_cdevsw = { .d_kqfilter = usbpf_kqfilter, }; +static struct cdev *usbpf_cdev; static LIST_HEAD(, usbpf_if) usbpf_iflist; static struct mtx usbpf_mtx; /* global lock */ static int usbpf_uifd_cnt; @@ -1850,13 +1851,26 @@ usbpf_append_bytes(struct usbpf_d *ud, caddr_t buf, u_int offset, void *src, static void usbpf_drvinit(void *unused) { - struct cdev *dev; mtx_init(&usbpf_mtx, "USB packet filter global lock", NULL, MTX_DEF); LIST_INIT(&usbpf_iflist); - dev = make_dev(&usbpf_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "usbpf"); + usbpf_cdev = make_dev(&usbpf_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, + "usbpf"); +} + +static void +usbpf_drvuninit(void) +{ + + if (usbpf_cdev != NULL) { + destroy_dev(usbpf_cdev); + usbpf_cdev = NULL; + } + mtx_destroy(&usbpf_mtx); } SYSINIT(usbpf_dev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, usbpf_drvinit, NULL); +SYSUNINIT(usbpf_undev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, usbpf_drvuninit, NULL); + |