]> git.neil.brown.name Git - history.git/commitdiff
module.c: allow modules to enter themselves during mod init
authorDoug Ledford <dledford@aladin.rdu.redhat.com>
Sun, 17 Nov 2002 11:32:15 +0000 (06:32 -0500)
committerDoug Ledford <dledford@flossy.devel.redhat.com>
Sun, 17 Nov 2002 11:32:15 +0000 (06:32 -0500)
kernel/module.c

index 668406fa22cd6ec4b09d12f46676da1ced80296b..9b8212cd32e1f68b38464d00418c8889c995f6c9 100644 (file)
@@ -1058,6 +1058,15 @@ sys_init_module(void *umod,
        list_add(&mod->extable.list, &extables);
        spin_unlock_irq(&modlist_lock);
 
+       /* Note, setting the mod->live to 1 here is safe because we haven't
+        * linked the module into the system's kernel symbol table yet,
+        * which means that the only way any other kernel code can call
+        * into this module right now is if this module hands out entry
+        * pointers to the other code.  We assume that no module hands out
+        * entry pointers to the rest of the kernel unless it is ready to
+        * have them used.
+        */
+       mod->live = 1;
        /* Start the module */
        ret = mod->init ? mod->init() : 0;
        if (ret < 0) {
@@ -1070,9 +1079,10 @@ sys_init_module(void *umod,
                        /* Mark it "live" so that they can force
                           deletion later, and we don't keep getting
                           woken on every decrement. */
-                       mod->live = 1;
-               } else
+               } else {
+                       mod->live = 0;
                        free_module(mod);
+               }
                up(&module_mutex);
                return ret;
        }
@@ -1087,7 +1097,6 @@ sys_init_module(void *umod,
        mod->module_init = NULL;
 
        /* All ok! */
-       mod->live = 1;
        up(&module_mutex);
        return 0;
 }