From owner-svn-src-stable-8@FreeBSD.ORG Sat Aug 29 15:42:06 2009 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C7E69106564A; Sat, 29 Aug 2009 15:42:06 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B4B738FC22; Sat, 29 Aug 2009 15:42:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7TFg69i068240; Sat, 29 Aug 2009 15:42:06 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7TFg6On068238; Sat, 29 Aug 2009 15:42:06 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200908291542.n7TFg6On068238@svn.freebsd.org> From: Andrew Thompson Date: Sat, 29 Aug 2009 15:42:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196642 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/usb dev/xen/xenpci X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Aug 2009 15:42:06 -0000 Author: thompsa Date: Sat Aug 29 15:42:06 2009 New Revision: 196642 URL: http://svn.freebsd.org/changeset/base/196642 Log: MFC r196547 It is possible for all the kthreads to exit (hci modules unloaded) which in turn ends our usb process. This means the proc pointer becomes invalid and will panic if a new kthread is added. Count the number of threads and clear the proc pointer on the last one. Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/usb/usb_process.c stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/usb/usb_process.c ============================================================================== --- stable/8/sys/dev/usb/usb_process.c Sat Aug 29 15:21:50 2009 (r196641) +++ stable/8/sys/dev/usb/usb_process.c Sat Aug 29 15:42:06 2009 (r196642) @@ -64,6 +64,7 @@ #if (__FreeBSD_version >= 800000) static struct proc *usbproc; +static int usb_pcount; #define USB_THREAD_CREATE(f, s, p, ...) \ kproc_kthread_add((f), (s), &usbproc, (p), RFHIGHPID, \ 0, "usb", __VA_ARGS__) @@ -183,6 +184,11 @@ usb_process(void *arg) up->up_ptr = NULL; cv_signal(&up->up_cv); mtx_unlock(up->up_mtx); +#if (__FreeBSD_version >= 800000) + /* Clear the proc pointer if this is the last thread. */ + if (--usb_pcount == 0) + usbproc = NULL; +#endif USB_THREAD_EXIT(0); } @@ -218,6 +224,9 @@ usb_proc_create(struct usb_process *up, up->up_ptr = NULL; goto error; } +#if (__FreeBSD_version >= 800000) + usb_pcount++; +#endif return (0); error: