From owner-svn-src-all@FreeBSD.ORG Wed Apr 15 16:22:07 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1F214A3C; Wed, 15 Apr 2015 16:22:07 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E3A61968; Wed, 15 Apr 2015 16:22:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3FGM6pN057151; Wed, 15 Apr 2015 16:22:06 GMT (envelope-from neel@FreeBSD.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3FGM6ef057150; Wed, 15 Apr 2015 16:22:06 GMT (envelope-from neel@FreeBSD.org) Message-Id: <201504151622.t3FGM6ef057150@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: neel set sender to neel@FreeBSD.org using -f From: Neel Natu Date: Wed, 15 Apr 2015 16:22:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r281559 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Apr 2015 16:22:07 -0000 Author: neel Date: Wed Apr 15 16:22:05 2015 New Revision: 281559 URL: https://svnweb.freebsd.org/changeset/base/281559 Log: Fix handling of BUS_PROBE_NOWILDCARD in 'device_probe_child()'. Device probe value of BUS_PROBE_NOWILDCARD should be treated specially only if the device has a fixed devclass. Otherwise it should be interpreted just as if the driver doesn't want to claim the device. Prior to this change a device that was not claimed explicitly by its driver would remain "attached" to the driver that returned BUS_PROBE_NOWILDCARD. This would bump up the reference on 'driver->refs' and its 'dev->ops' would point to the 'driver->ops'. When the driver is subsequently unloaded the 'dev->ops->cls' is left pointing to freed memory. This fixes an easily reproducible #GP fault caused by loading and unloading vmm.ko multiple times. Differential Revision: https://reviews.freebsd.org/D2294 Reviewed by: imp, jhb Discussed with: rstone Reported by: Leon Dang (ldang@nahannisys.com) MFC after: 2 weeks Modified: head/sys/kern/subr_bus.c Modified: head/sys/kern/subr_bus.c ============================================================================== --- head/sys/kern/subr_bus.c Wed Apr 15 14:46:45 2015 (r281558) +++ head/sys/kern/subr_bus.c Wed Apr 15 16:22:05 2015 (r281559) @@ -2113,6 +2113,16 @@ device_probe_child(device_t dev, device_ } /* + * Probes that return BUS_PROBE_NOWILDCARD or lower + * only match on devices whose driver was explicitly + * specified. + */ + if (result <= BUS_PROBE_NOWILDCARD && + !(child->flags & DF_FIXEDCLASS)) { + result = ENXIO; + } + + /* * The driver returned an error so it * certainly doesn't match. */ @@ -2127,14 +2137,6 @@ device_probe_child(device_t dev, device_ * of pri for the first match. */ if (best == NULL || result > pri) { - /* - * Probes that return BUS_PROBE_NOWILDCARD - * or lower only match on devices whose - * driver was explicitly specified. - */ - if (result <= BUS_PROBE_NOWILDCARD && - !(child->flags & DF_FIXEDCLASS)) - continue; best = dl; pri = result; continue;