Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern When modules are unloaded, we call sysctl_teardown(...



details:   https://anonhg.NetBSD.org/src/rev/957df869842d
branches:  trunk
changeset: 458747:957df869842d
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Thu Aug 08 18:08:41 2019 +0000

description:
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.

diffstat:

 sys/kern/kern_module.c |  13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diffs (41 lines):

diff -r 83f120a8f999 -r 957df869842d sys/kern/kern_module.c
--- a/sys/kern/kern_module.c    Thu Aug 08 18:03:40 2019 +0000
+++ b/sys/kern/kern_module.c    Thu Aug 08 18:08:41 2019 +0000
@@ -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_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 @@
        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) {



Home | Main Index | Thread Index | Old Index