From owner-svn-src-all@FreeBSD.ORG Wed Oct 8 08:08:03 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 722A210656A2; Wed, 8 Oct 2008 08:08:03 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 60A158FC18; Wed, 8 Oct 2008 08:08:03 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id m98883S2028096; Wed, 8 Oct 2008 08:08:03 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m98883NQ028095; Wed, 8 Oct 2008 08:08:03 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200810080808.m98883NQ028095@svn.freebsd.org> From: Warner Losh Date: Wed, 8 Oct 2008 08:08:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r183692 - head/sys/dev/sio X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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, 08 Oct 2008 08:08:03 -0000 Author: imp Date: Wed Oct 8 08:08:03 2008 New Revision: 183692 URL: http://svn.freebsd.org/changeset/base/183692 Log: Add a note about a bug in how sio manages its softc. This was discovered by Dorr H. Clark. I'm not at all sure how to fix it, but wanted to document it at the very least... Modified: head/sys/dev/sio/sio.c Modified: head/sys/dev/sio/sio.c ============================================================================== --- head/sys/dev/sio/sio.c Wed Oct 8 06:39:05 2008 (r183691) +++ head/sys/dev/sio/sio.c Wed Oct 8 08:08:03 2008 (r183692) @@ -696,6 +696,14 @@ sioprobe(dev, xrid, rclk, noprobe) bus_release_resource(dev, SYS_RES_IOPORT, rid, port); if (iobase == siocniobase) result = 0; + /* + * XXX: Since we don't return 0, we shouldn't be relying on + * the softc that we set to persist to the call to attach + * since other probe routines may be called, and the malloc + * here causes subr_bus to not allocate anything for the + * other probes. Instead, this softc is preserved and other + * probe routines can corrupt it. + */ if (result != 0) { device_set_softc(dev, NULL); free(com, M_DEVBUF); @@ -773,6 +781,13 @@ sioprobe(dev, xrid, rclk, noprobe) bus_release_resource(dev, SYS_RES_IOPORT, rid, port); if (iobase == siocniobase) result = 0; + /* + * XXX: Since we don't return 0, we shouldn't be relying on the softc + * that we set to persist to the call to attach since other probe + * routines may be called, and the malloc here causes subr_bus to not + * allocate anything for the other probes. Instead, this softc is + * preserved and other probe routines can corrupt it. + */ if (result != 0) { device_set_softc(dev, NULL); free(com, M_DEVBUF);