Commit 6494a93d55fad586238cc1940e846c6d03e1aaf6
Committed by
Rusty Russell
1 parent
0aa5bd52d0
Exists in
master
and in
7 other branches
Module: check to see if we have a built in module with the same name
When trying to load a module with the same name as a built-in one, a scary kobject backtrace comes up. Prevent that from checking for this condition and warning the user as to what exactly is going on. Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Showing 1 changed file with 10 additions and 0 deletions Side-by-side Diff
kernel/module.c
... | ... | @@ -1230,6 +1230,7 @@ |
1230 | 1230 | int mod_sysfs_init(struct module *mod) |
1231 | 1231 | { |
1232 | 1232 | int err; |
1233 | + struct kobject *kobj; | |
1233 | 1234 | |
1234 | 1235 | if (!module_sysfs_initialized) { |
1235 | 1236 | printk(KERN_ERR "%s: module sysfs not initialized\n", |
... | ... | @@ -1237,6 +1238,15 @@ |
1237 | 1238 | err = -EINVAL; |
1238 | 1239 | goto out; |
1239 | 1240 | } |
1241 | + | |
1242 | + kobj = kset_find_obj(module_kset, mod->name); | |
1243 | + if (kobj) { | |
1244 | + printk(KERN_ERR "%s: module is already loaded\n", mod->name); | |
1245 | + kobject_put(kobj); | |
1246 | + err = -EINVAL; | |
1247 | + goto out; | |
1248 | + } | |
1249 | + | |
1240 | 1250 | mod->mkobj.mod = mod; |
1241 | 1251 | |
1242 | 1252 | memset(&mod->mkobj.kobj, 0, sizeof(mod->mkobj.kobj)); |