git: 19866d1a162f - stable/13 - ofwbus: only allow unit number zero
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 17 Apr 2023 17:04:02 UTC
The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=19866d1a162fca492ca5a7776d209d1ea4ae565e commit 19866d1a162fca492ca5a7776d209d1ea4ae565e Author: Mitchell Horne <mhorne@FreeBSD.org> AuthorDate: 2023-02-13 17:44:03 +0000 Commit: Mitchell Horne <mhorne@FreeBSD.org> CommitDate: 2023-04-17 16:54:04 +0000 ofwbus: only allow unit number zero ofwbus has always been the root of attachment for OFW/FDT platforms. It may have simplebus children, but we expect only one instance of the ofwbus driver, added directly by nexus. We may as well ensure this remains the case. Reviewed by: jhb MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D38493 (cherry picked from commit afca197f5240ce2c2c7abfe5c9fbc50ba55f178b) --- sys/dev/ofw/ofwbus.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/dev/ofw/ofwbus.c b/sys/dev/ofw/ofwbus.c index 7660be8cec39..c97fd41bb683 100644 --- a/sys/dev/ofw/ofwbus.c +++ b/sys/dev/ofw/ofwbus.c @@ -98,6 +98,11 @@ ofwbus_probe(device_t dev) if (OF_peer(0) == 0) return (ENXIO); + /* Only one instance of ofwbus. */ + if (device_get_unit(dev) != 0) + panic("ofwbus added with non-zero unit number: %d\n", + device_get_unit(dev)); + device_set_desc(dev, "Open Firmware Device Tree"); return (BUS_PROBE_NOWILDCARD); }