]> Pileus Git - ~andy/linux/blobdiff - kernel/module.c
cpuset: remove cpuset_test_cpumask()
[~andy/linux] / kernel / module.c
index 0925c9a719753f19085ee267edfc643205c752aa..b049939177f6d3a4983341b42eb4719c27b4af62 100644 (file)
@@ -1209,10 +1209,11 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,
 
        /* Since this should be found in kernel (which can't be removed),
         * no locking is necessary. */
-       if (!find_symbol(MODULE_SYMBOL_PREFIX "module_layout", NULL,
+       if (!find_symbol(VMLINUX_SYMBOL_STR(module_layout), NULL,
                         &crc, true, false))
                BUG();
-       return check_version(sechdrs, versindex, "module_layout", mod, crc,
+       return check_version(sechdrs, versindex,
+                            VMLINUX_SYMBOL_STR(module_layout), mod, crc,
                             NULL);
 }
 
@@ -1861,12 +1862,12 @@ static void free_module(struct module *mod)
 {
        trace_module_free(mod);
 
-       /* Delete from various lists */
-       mutex_lock(&module_mutex);
-       stop_machine(__unlink_module, mod, NULL);
-       mutex_unlock(&module_mutex);
        mod_sysfs_teardown(mod);
 
+       /* We leave it in list to prevent duplicate loads, but make sure
+        * that noone uses it while it's being deconstructed. */
+       mod->state = MODULE_STATE_UNFORMED;
+
        /* Remove dynamic debug info */
        ddebug_remove_module(mod->name);
 
@@ -1879,6 +1880,11 @@ static void free_module(struct module *mod)
        /* Free any allocated parameters. */
        destroy_params(mod->kp, mod->num_kp);
 
+       /* Now we can delete it from the lists */
+       mutex_lock(&module_mutex);
+       stop_machine(__unlink_module, mod, NULL);
+       mutex_unlock(&module_mutex);
+
        /* This may be NULL, but that's OK */
        unset_module_init_ro_nx(mod);
        module_free(mod, mod->module_init);