Module Name: src
Committed By: pgoyette
Date: Thu Aug 8 18:08:41 UTC 2019
Modified Files:
src/sys/kern: kern_module.c
Log Message:
When modules are unloaded, we call sysctl_teardown() before calling
the module's modcmd(CMD_FINI) code. If the modcmd() call returns an
error, we attempted to re-instate the module's sysctl stuff.
This doesn't work well for built-in modulesi (where "unload" actually
means "disable"), since they don't have any ``struct kobj''.
So check first, and don't try to find the __link_set_sysctl_funcs for
built-in modules.
To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/sys/kern/kern_module.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/kern_module.c
diff -u src/sys/kern/kern_module.c:1.137 src/sys/kern/kern_module.c:1.138
--- src/sys/kern/kern_module.c:1.137 Wed Aug 7 00:38:02 2019
+++ src/sys/kern/kern_module.c Thu Aug 8 18:08:41 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_module.c,v 1.137 2019/08/07 00:38:02 pgoyette Exp $ */
+/* $NetBSD: kern_module.c,v 1.138 2019/08/08 18:08:41 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.137 2019/08/07 00:38:02 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.138 2019/08/08 18:08:41 pgoyette Exp $");
#define _MODULE_INTERNAL
@@ -949,7 +949,7 @@ module_do_builtin(const module_t *pmod,
/*
* module_load_sysctl
*
- * Check to see if the module has any SYSCTL_SETUP() routine(s)
+ * Check to see if a non-builtin module has any SYSCTL_SETUP() routine(s)
* registered. If so, call it (them).
*/
@@ -961,6 +961,13 @@ module_load_sysctl(module_t *mod)
size_t ls_size, count;
int error;
+ /*
+ * Built-in modules don't have a mod_kobj so we cannot search
+ * for their link_set_sysctl_funcs
+ */
+ if (mod->mod_source == MODULE_SOURCE_KERNEL)
+ return;
+
error = kobj_find_section(mod->mod_kobj, "link_set_sysctl_funcs",
&ls_start, &ls_size);
if (error == 0) {