From 9ffaa8008fb0f83e062e076c52a5df2364a63a8b Mon Sep 17 00:00:00 2001 From: patrick Date: Sat, 5 Nov 2022 18:56:09 +0000 Subject: [PATCH] Make sure fdt_find_node() returns NULL if it can't find the requested node. ok kettenis@ --- sys/arch/arm64/stand/efiboot/fdt.c | 5 ++++- sys/arch/armv7/stand/efiboot/fdt.c | 5 ++++- sys/arch/riscv64/stand/efiboot/fdt.c | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/sys/arch/arm64/stand/efiboot/fdt.c b/sys/arch/arm64/stand/efiboot/fdt.c index e2c3a8a2393..b1e3d6ebb14 100644 --- a/sys/arch/arm64/stand/efiboot/fdt.c +++ b/sys/arch/arm64/stand/efiboot/fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdt.c,v 1.6 2022/03/14 19:09:32 kettenis Exp $ */ +/* $OpenBSD: fdt.c,v 1.7 2022/11/05 18:56:09 patrick Exp $ */ /* * Copyright (c) 2009 Dariusz Swiderski @@ -494,6 +494,9 @@ fdt_find_node(char *name) } } + if (child == NULL) + return NULL; /* No match found. */ + p = q; } diff --git a/sys/arch/armv7/stand/efiboot/fdt.c b/sys/arch/armv7/stand/efiboot/fdt.c index 3556a5a6b23..9c49b840a28 100644 --- a/sys/arch/armv7/stand/efiboot/fdt.c +++ b/sys/arch/armv7/stand/efiboot/fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdt.c,v 1.8 2022/03/14 19:09:32 kettenis Exp $ */ +/* $OpenBSD: fdt.c,v 1.9 2022/11/05 18:56:09 patrick Exp $ */ /* * Copyright (c) 2009 Dariusz Swiderski @@ -494,6 +494,9 @@ fdt_find_node(char *name) } } + if (child == NULL) + return NULL; /* No match found. */ + p = q; } diff --git a/sys/arch/riscv64/stand/efiboot/fdt.c b/sys/arch/riscv64/stand/efiboot/fdt.c index 45a280f9465..7fbc0a8e4b8 100644 --- a/sys/arch/riscv64/stand/efiboot/fdt.c +++ b/sys/arch/riscv64/stand/efiboot/fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdt.c,v 1.2 2022/03/14 19:09:32 kettenis Exp $ */ +/* $OpenBSD: fdt.c,v 1.3 2022/11/05 18:56:09 patrick Exp $ */ /* * Copyright (c) 2009 Dariusz Swiderski @@ -494,6 +494,9 @@ fdt_find_node(char *name) } } + if (child == NULL) + return NULL; /* No match found. */ + p = q; } -- 2.20.1