diff --git a/sys/kern/kern_module.c b/sys/kern/kern_module.c index 5c80d986d6ab..b734a0959cb8 100644 --- a/sys/kern/kern_module.c +++ b/sys/kern/kern_module.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_module.c,v 1.120 2017/02/01 01:51:07 maya Exp $ */ +/* $NetBSD: kern_module.c,v 1.121 2017/04/11 14:31:55 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.120 2017/02/01 01:51:07 maya Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.121 2017/04/11 14:31:55 christos Exp $"); #define _MODULE_INTERNAL @@ -54,6 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.120 2017/02/01 01:51:07 maya Exp $ #include #include #include +#include #include @@ -608,6 +609,14 @@ module_autoload(const char *filename, modclass_t modclass) { int error; + if (rootvnode == NULL) { +#ifdef DIAGNOSTIC + printf("%s: trying to load `%s' before root is mounted\n", + __func__, filename); +#endif + return; + } + kernconfig_lock(); /* Nothing if the user has disabled it. */