Date: Thu, 28 Feb 2019 22:10:19 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r344671 - head/sys/dev/cxgbe Message-ID: <201902282210.x1SMAJAt027498@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902282210.x1SMAJAt027498>