Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/macppc/macppc check for proper error value from OF_...



details:   https://anonhg.NetBSD.org/src/rev/a0b7b2c3e9a6
branches:  trunk
changeset: 374647:a0b7b2c3e9a6
user:      macallan <macallan%NetBSD.org@localhost>
date:      Tue May 09 10:49:46 2023 +0000

description:
check for proper error value from OF_finddevice()
should fix PR57394

diffstat:

 sys/arch/macppc/macppc/mainbus.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r 4426cc5042a3 -r a0b7b2c3e9a6 sys/arch/macppc/macppc/mainbus.c
--- a/sys/arch/macppc/macppc/mainbus.c  Tue May 09 10:42:34 2023 +0000
+++ b/sys/arch/macppc/macppc/mainbus.c  Tue May 09 10:49:46 2023 +0000
@@ -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";



Home | Main Index | Thread Index | Old Index