From f56e72c60ab5845ad8060c2482bebfd92690e838 Mon Sep 17 00:00:00 2001 From: dlg Date: Mon, 3 Apr 2023 01:34:06 +0000 Subject: [PATCH] special case phandle 0 and return NULL when looking up network interfaces. not all interfaces will have a phandle (ie, it will be 0), so don't let phandle 0 be used to find any of these. discussed with miod@ --- sys/dev/ofw/ofw_misc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/dev/ofw/ofw_misc.c b/sys/dev/ofw/ofw_misc.c index 2e42efc0686..5f3a21486de 100644 --- a/sys/dev/ofw/ofw_misc.c +++ b/sys/dev/ofw/ofw_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofw_misc.c,v 1.39 2023/04/03 01:30:32 dlg Exp $ */ +/* $OpenBSD: ofw_misc.c,v 1.40 2023/04/03 01:34:06 dlg Exp $ */ /* * Copyright (c) 2017-2021 Mark Kettenis * @@ -152,6 +152,9 @@ if_byphandle(uint32_t phandle) { struct if_device *ifd; + if (phandle == 0) + return (NULL); + LIST_FOREACH(ifd, &if_devices, if_list) { if (ifd->if_phandle == phandle) return (ifd->if_ifp); -- 2.20.1