From: mpi Date: Sun, 18 Sep 2022 14:41:54 +0000 (+0000) Subject: Revert previous it prevents the PinebookPro and the Rockpro64 to reach userland. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4f49b3e389ee789ba2e9f7a4349218cef4447827;p=openbsd Revert previous it prevents the PinebookPro and the Rockpro64 to reach userland. Found by kn@ and myself, ok deraadt@ --- diff --git a/sys/dev/ofw/fdt.c b/sys/dev/ofw/fdt.c index 834c83ad55d..e6593d61b32 100644 --- a/sys/dev/ofw/fdt.c +++ b/sys/dev/ofw/fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdt.c,v 1.31 2022/09/11 08:33:03 kettenis Exp $ */ +/* $OpenBSD: fdt.c,v 1.32 2022/09/18 14:41:54 mpi Exp $ */ /* * Copyright (c) 2009 Dariusz Swiderski @@ -882,33 +882,16 @@ int OF_getnodebyname(int handle, const char *name) { void *node = (char *)tree.header + handle; - void *child; - char *data; - int len; if (handle == 0) node = fdt_find_node("/"); - for (child = fdt_child_node(node); child; - child = fdt_next_node(child)) { - if (strcmp(name, fdt_node_name(child)) == 0) + for (node = fdt_child_node(node); node; node = fdt_next_node(node)) { + if (strcmp(name, fdt_node_name(node)) == 0) break; } - if (child) - return (char *)child - (char *)tree.header; - - len = strlen(name); - for (child = fdt_child_node(node); child; - child = fdt_next_node(node)) { - data = fdt_node_name(child); - if (strncmp(name, data, len) == 0 && - strlen(data) > len && data[len] == '@') - break; - } - if (child) - return (char *)child - (char *)tree.header; - return 0; + return node ? ((char *)node - (char *)tree.header) : 0; } int