diff --git a/kernel/module.c b/kernel/module.c index 1bb4c5e0d56e330b1de92b5e20fddbd446e9d314..76ddc85a423ad2eabd3d1ace1cbbb772cd06f10a 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1214,6 +1214,7 @@ void module_remove_modinfo_attrs(struct module *mod) int mod_sysfs_init(struct module *mod) { int err; + struct kobject *kobj; if (!module_sysfs_initialized) { printk(KERN_ERR "%s: module sysfs not initialized\n", @@ -1221,6 +1222,15 @@ int mod_sysfs_init(struct module *mod) err = -EINVAL; goto out; } + + kobj = kset_find_obj(module_kset, mod->name); + if (kobj) { + printk(KERN_ERR "%s: module is already loaded\n", mod->name); + kobject_put(kobj); + err = -EINVAL; + goto out; + } + mod->mkobj.mod = mod; memset(&mod->mkobj.kobj, 0, sizeof(mod->mkobj.kobj));