summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_linker.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2004-05-17 21:24:39 +0000
committerpeter <peter@FreeBSD.org>2004-05-17 21:24:39 +0000
commit867065a3a418323789efe426e031d71e7ce8d050 (patch)
tree342faec78e4f3fb16eee8ce47bbeff7299bf6c0e /sys/kern/kern_linker.c
parent479e3fd6313bd41cb7c2f1ecca4439ee00b3a926 (diff)
downloadFreeBSD-src-867065a3a418323789efe426e031d71e7ce8d050.zip
FreeBSD-src-867065a3a418323789efe426e031d71e7ce8d050.tar.gz
Since we go to the trouble of compiling the kobj ops table for each class,
and cannot handle it going away, add an explicit reference to the kobj class inside each linker class. Without this, a class with no modules loaded will sit with an idle refcount of 0. Loading and unloading a module with it causes a 0->1->0 transition which frees the ops table and causes subsequent loads using that class to explode. Normally, the "kernel" module will remain forever loaded and prevent this happening, but if you have more than one linker class active, only one owns the "kernel". This finishes making modules work for kldload(8) on amd64.
Diffstat (limited to 'sys/kern/kern_linker.c')
-rw-r--r--sys/kern/kern_linker.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index ff5d91b..fe339dd 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -147,6 +147,7 @@ linker_add_class(linker_class_t lc)
if (linker_no_more_classes == 1)
return (EPERM);
kobj_class_compile((kobj_class_t) lc);
+ ((kobj_class_t)lc)->refs++; /* prevent ops being freed */
TAILQ_INSERT_TAIL(&classes, lc, link);
return (0);
}
OpenPOWER on IntegriCloud