summaryrefslogtreecommitdiff
path: root/sys/kern/kern_module.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2008-12-05 16:47:30 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2008-12-05 16:47:30 +0000
commit75444a8590b1bba8cb7f7b60697627f193d7db4c (patch)
treebc48edf62c21c5ab7dd0d350384090ef84220711 /sys/kern/kern_module.c
parent3027fbe00bda3964010e3ff19cafd1cf517fb9f9 (diff)
Notes
Diffstat (limited to 'sys/kern/kern_module.c')
-rw-r--r--sys/kern/kern_module.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/kern/kern_module.c b/sys/kern/kern_module.c
index fef7f87652fb..9c53bf6f4638 100644
--- a/sys/kern/kern_module.c
+++ b/sys/kern/kern_module.c
@@ -130,6 +130,21 @@ module_register_init(const void *arg)
printf("module_register_init: MOD_LOAD (%s, %p, %p) error"
" %d\n", data->name, (void *)data->evhand, data->priv,
error);
+ } else {
+ MOD_XLOCK;
+ if (mod->file) {
+ /*
+ * Once a module is succesfully loaded, move
+ * it to the head of the module list for this
+ * linker file. This resorts the list so that
+ * when the kernel linker iterates over the
+ * modules to unload them, it will unload them
+ * in the reverse order they were loaded.
+ */
+ TAILQ_REMOVE(&mod->file->modules, mod, flink);
+ TAILQ_INSERT_HEAD(&mod->file->modules, mod, flink);
+ }
+ MOD_XUNLOCK;
}
mtx_unlock(&Giant);
}