Module Name: src Committed By: macallan Date: Tue May 9 10:49:47 UTC 2023
Modified Files: src/sys/arch/macppc/macppc: mainbus.c Log Message: check for proper error value from OF_finddevice() should fix PR57394 To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/arch/macppc/macppc/mainbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/macppc/macppc/mainbus.c diff -u src/sys/arch/macppc/macppc/mainbus.c:1.25 src/sys/arch/macppc/macppc/mainbus.c:1.26 --- src/sys/arch/macppc/macppc/mainbus.c:1.25 Sat Jan 22 11:49:16 2022 +++ src/sys/arch/macppc/macppc/mainbus.c Tue May 9 10:49:46 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.25 2022/01/22 11:49:16 thorpej Exp $ */ +/* $NetBSD: mainbus.c,v 1.26 2023/05/09 10:49:46 macallan Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.25 2022/01/22 11:49:16 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.26 2023/05/09 10:49:46 macallan Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -76,7 +76,13 @@ mainbus_attach(device_t parent, device_t devhandle_t selfh = device_handle(self); cpus = OF_finddevice("/cpus"); - if (cpus != 0) { + /* + * XXX + * the canonical error value is -1 but I dimly remember some OF + * variants returning 0 here, so check for both just in case. + * It's not like this is a performance critical path. + */ + if ((cpus != -1) && (cpus != 0)) { node = OF_child(cpus); while (node != 0) { ca.ca_name = "cpu";