From 6fc608bf2c6c3e59c2cc6276ccdbddbaa4a84722 Mon Sep 17 00:00:00 2001 From: Michal Meloun Date: Sun, 13 Dec 2015 09:05:55 +0000 Subject: [PATCH] SIMPLEBUS: Don't panic if child device doesn't have devinfo set. Strictly speaking, missing devinfo is error which can be caused by instantiating child using device_add_child() instead of BUS_ADD_CHILD(). However, we can tolerate it. Approved by: kib (mentor) --- sys/dev/fdt/simplebus.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c index 4cf063ed1a5..4e5bdd25b97 100644 --- a/sys/dev/fdt/simplebus.c +++ b/sys/dev/fdt/simplebus.c @@ -304,6 +304,8 @@ simplebus_get_devinfo(device_t bus __unused, device_t child) struct simplebus_devinfo *ndi; ndi = device_get_ivars(child); + if (ndi == NULL) + return (NULL); return (&ndi->obdinfo); } @@ -313,6 +315,8 @@ simplebus_get_resource_list(device_t bus __unused, device_t child) struct simplebus_devinfo *ndi; ndi = device_get_ivars(child); + if (ndi == NULL) + return (NULL); return (&ndi->rl); } @@ -380,6 +384,8 @@ simplebus_print_res(struct simplebus_devinfo *di) { int rv; + if (di == NULL) + return (0); rv = 0; rv += resource_list_print_type(&di->rl, "mem", SYS_RES_MEMORY, "%#lx"); rv += resource_list_print_type(&di->rl, "irq", SYS_RES_IRQ, "%ld");