[dev][console] Bail early if no root resource present
This situation appears in tests with isolated devmgr, when there is no
root resource.
Test: Booted
Change-Id: I5205001212079c1df5e0e9a4bc93a177a175f1cb
diff --git a/system/dev/misc/console/console.c b/system/dev/misc/console/console.c
index b939b72..8f0c8fe 100644
--- a/system/dev/misc/console/console.c
+++ b/system/dev/misc/console/console.c
@@ -130,6 +130,12 @@
};
static zx_status_t console_bind(void* ctx, zx_device_t* parent) {
+ // If we're in an isolated devmgr, we won't have the root resource. In that
+ // case, just don't bind this driver.
+ if (get_root_resource() == ZX_HANDLE_INVALID) {
+ return ZX_ERR_NOT_SUPPORTED;
+ }
+
console_device_t* console = calloc(1, sizeof(console_device_t));
if (!console) {
return ZX_ERR_NO_MEMORY;