From owner-freebsd-bugs Tue Jan 8 15:20:15 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 68A3937B41A for ; Tue, 8 Jan 2002 15:20:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g08NK1e05280; Tue, 8 Jan 2002 15:20:01 -0800 (PST) (envelope-from gnats) Received: from h132-197-179-27.gte.com (h132-197-179-27.gte.com [132.197.179.27]) by hub.freebsd.org (Postfix) with ESMTP id 774E537B41F; Tue, 8 Jan 2002 15:12:28 -0800 (PST) Received: (from ak03@localhost) by h132-197-179-27.gte.com (8.11.6/8.11.4) id g08NCRR86733; Tue, 8 Jan 2002 18:12:27 -0500 (EST) (envelope-from ak03) Message-Id: <200201082312.g08NCRR86733@h132-197-179-27.gte.com> Date: Tue, 8 Jan 2002 18:12:27 -0500 (EST) From: "Alexander N. Kabaev" Reply-To: "Alexander N. Kabaev" To: FreeBSD-gnats-submit@freebsd.org Cc: Josef Karthauser X-Send-Pr-Version: 3.113 Subject: kern/33712: Duplicate make_dev panic in ugen.c + patch Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 33712 >Category: kern >Synopsis: Duplicate make_dev panic in ugen.c + patch >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Jan 08 15:20:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Alexander N. Kabaev >Release: FreeBSD 5.0-CURRENT i386 >Organization: Verizon Data Services >Environment: System: FreeBSD kanpc.gte.com 5.0-CURRENT FreeBSD 5.0-CURRENT #20: Mon Jan 7 17:20:17 EST 2002 root@kanpc.gte.com:/usr/src/sys/i386/compile/KANPC i386 >Description: It is possible to get the "duplicate make_dev: Don't do that" panic in ugen.c if USB device has not been recognised or is failed to attach for the first time, because ugen_attach functions always attempts to create make_dev but fails to clean-up after itself on failure. >How-To-Repeat: Get crappy motherboard with which USB interrupt delivery is not working at the hardware probing time but works just fine as soon an system reaches multi-user mode and buy a Microsoft IntelliMouse USB? Interrupts problem will be reported separately. >Fix: Proposed patch moves control device node creation/destruction into ugen_make_devnodes/ugen_destroy_devnodes functions respectively. This way device nodes are not created unless device probe is finished successfully and the whole problem is just eliminated. Also has nice side effect of removing some ugly __FreeBSD__ ifdefs. Index: ugen.c =================================================================== RCS file: /usr/ncvs/src/sys/dev/usb/ugen.c,v retrieving revision 1.56 diff -u -r1.56 ugen.c --- ugen.c 2 Jan 2002 23:31:08 -0000 1.56 +++ ugen.c 8 Jan 2002 22:52:44 -0000 @@ -202,11 +202,6 @@ sc->sc_udev = udev = uaa->device; -#if defined(__FreeBSD__) - /* the main device, ctrl endpoint */ - make_dev(&ugen_cdevsw, UGENMINOR(USBDEVUNIT(sc->sc_dev), 0), - UID_ROOT, GID_OPERATOR, 0644, "%s", USBDEVNAME(sc->sc_dev)); -#endif memset(sc->sc_endpoints, 0, sizeof sc->sc_endpoints); /* First set configuration index 0, the default one for ugen. */ @@ -237,6 +232,10 @@ { int endptno; + /* the main device, ctrl endpoint */ + make_dev(&ugen_cdevsw, UGENMINOR(USBDEVUNIT(sc->sc_dev), 0), + UID_ROOT, GID_OPERATOR, 0644, "%s", USBDEVNAME(sc->sc_dev)); + for (endptno = 1; endptno < USB_MAX_ENDPOINTS; endptno++) { if (sc->sc_endpoints[endptno][IN].sc != NULL || sc->sc_endpoints[endptno][OUT].sc != NULL ) { @@ -264,6 +263,13 @@ dev_t dev; struct vnode *vp; + /* destroy the device for the control endpoint */ + dev = makedev(UGEN_CDEV_MAJOR, UGENMINOR(USBDEVUNIT(sc->sc_dev), 0)); + vp = SLIST_FIRST(&dev->si_hlist); + if (vp) + VOP_REVOKE(vp, REVOKEALL); + destroy_dev(dev); + /* destroy all devices for the other (existing) endpoints as well */ for (endptno = 1; endptno < USB_MAX_ENDPOINTS; endptno++) { if (sc->sc_endpoints[endptno][IN].sc != NULL || @@ -816,9 +822,6 @@ int s; #if defined(__NetBSD__) || defined(__OpenBSD__) int maj, mn; -#elif defined(__FreeBSD__) - dev_t dev; - struct vnode *vp; #endif #if defined(__NetBSD__) || defined(__OpenBSD__) @@ -857,12 +860,6 @@ mn = self->dv_unit * USB_MAX_ENDPOINTS; vdevgone(maj, mn, mn + USB_MAX_ENDPOINTS - 1, VCHR); #elif defined(__FreeBSD__) - /* destroy the device for the control endpoint */ - dev = makedev(UGEN_CDEV_MAJOR, UGENMINOR(USBDEVUNIT(sc->sc_dev), 0)); - vp = SLIST_FIRST(&dev->si_hlist); - if (vp) - VOP_REVOKE(vp, REVOKEALL); - destroy_dev(dev); ugen_destroy_devnodes(sc); #endif >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message