diff options
-rw-r--r-- | kernel/module.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/kernel/module.c b/kernel/module.c index 3c2c72d3bf84..b049939177f6 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -1862,12 +1862,12 @@ static void free_module(struct module *mod) | |||
1862 | { | 1862 | { |
1863 | trace_module_free(mod); | 1863 | trace_module_free(mod); |
1864 | 1864 | ||
1865 | /* Delete from various lists */ | ||
1866 | mutex_lock(&module_mutex); | ||
1867 | stop_machine(__unlink_module, mod, NULL); | ||
1868 | mutex_unlock(&module_mutex); | ||
1869 | mod_sysfs_teardown(mod); | 1865 | mod_sysfs_teardown(mod); |
1870 | 1866 | ||
1867 | /* We leave it in list to prevent duplicate loads, but make sure | ||
1868 | * that noone uses it while it's being deconstructed. */ | ||
1869 | mod->state = MODULE_STATE_UNFORMED; | ||
1870 | |||
1871 | /* Remove dynamic debug info */ | 1871 | /* Remove dynamic debug info */ |
1872 | ddebug_remove_module(mod->name); | 1872 | ddebug_remove_module(mod->name); |
1873 | 1873 | ||
@@ -1880,6 +1880,11 @@ static void free_module(struct module *mod) | |||
1880 | /* Free any allocated parameters. */ | 1880 | /* Free any allocated parameters. */ |
1881 | destroy_params(mod->kp, mod->num_kp); | 1881 | destroy_params(mod->kp, mod->num_kp); |
1882 | 1882 | ||
1883 | /* Now we can delete it from the lists */ | ||
1884 | mutex_lock(&module_mutex); | ||
1885 | stop_machine(__unlink_module, mod, NULL); | ||
1886 | mutex_unlock(&module_mutex); | ||
1887 | |||
1883 | /* This may be NULL, but that's OK */ | 1888 | /* This may be NULL, but that's OK */ |
1884 | unset_module_init_ro_nx(mod); | 1889 | unset_module_init_ro_nx(mod); |
1885 | module_free(mod, mod->module_init); | 1890 | module_free(mod, mod->module_init); |