svn commit: r344671 - head/sys/dev/cxgbe

John Baldwin jhb at FreeBSD.org
Thu Feb 28 22:10:20 UTC 2019


Author: jhb
Date: Thu Feb 28 22:10:19 2019
New Revision: 344671
URL: https://svnweb.freebsd.org/changeset/base/344671

Log:
  Don't assume all children of a nexus are ports.
  
  Specifically, ccr(4) devices are also children of cxgbe nexus devices.
  Rather than making assumptions about the child device's softc, walk
  the list of ports from the nexus' softc to determine if a child is a
  port in t4_child_location_str().  This fixes a panic when detaching a
  ccr device.
  
  Reviewed by:	np
  MFC after:	1 week
  Sponsored by:	Chelsio Communications
  Differential Revision:	https://reviews.freebsd.org/D19399

Modified:
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c	Thu Feb 28 22:00:36 2019	(r344670)
+++ head/sys/dev/cxgbe/t4_main.c	Thu Feb 28 22:10:19 2019	(r344671)
@@ -1372,10 +1372,19 @@ done:
 static int
 t4_child_location_str(device_t bus, device_t dev, char *buf, size_t buflen)
 {
+	struct adapter *sc;
 	struct port_info *pi;
+	int i;
 
-	pi = device_get_softc(dev);
-	snprintf(buf, buflen, "port=%d", pi->port_id);
+	sc = device_get_softc(bus);
+	buf[0] = '\0';
+	for_each_port(sc, i) {
+		pi = sc->port[i];
+		if (pi != NULL && pi->dev == dev) {
+			snprintf(buf, buflen, "port=%d", pi->port_id);
+			break;
+		}
+	}
 	return (0);
 }
 


More information about the svn-src-head mailing list