From 23eb3eb66e293167d47dcaebfe2ef39e4e4727c6 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Mon, 17 May 2004 21:24:39 +0000 Subject: [PATCH] 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. --- sys/kern/kern_linker.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index ff5d91b421b..fe339dd7270 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); }