svn commit: r183692 - head/sys/dev/sio

Warner Losh imp at FreeBSD.org
Wed Oct 8 08:08:03 UTC 2008


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);


More information about the svn-src-all mailing list