[PATCH 3/5] Module: check to see if we have a built in module with the same name

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Cc: Greg Kroah-Hartman <gregkh@...>, Rusty Russell <rusty@...>, Linus Torvalds <torvalds@...>, Andrew Morton <akpm@...>
Date: Sunday, January 27, 2008 - 7:38 pm

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>
---
 kernel/module.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 1bb4c5e..76ddc85 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));
-- 
1.5.3.8

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[GIT PATCH] driver core fixes against 2.6.24, Greg KH, (Sun Jan 27, 7:37 pm)
[PATCH 5/5] PPC: Fix powerpc vio_find_name to not use device..., Greg Kroah-Hartman, (Sun Jan 27, 7:38 pm)
[PATCH 4/5] Driver core: add bus_find_device_by_name function, Greg Kroah-Hartman, (Sun Jan 27, 7:38 pm)
[PATCH 3/5] Module: check to see if we have a built in modul..., Greg Kroah-Hartman, (Sun Jan 27, 7:38 pm)
[PATCH 2/5] x86: fix runtime error in arch/x86/kernel/cpu/mc..., Greg Kroah-Hartman, (Sun Jan 27, 7:38 pm)
[PATCH 1/5] Driver core: Fix up build when CONFIG_BLOCK=N, Greg Kroah-Hartman, (Sun Jan 27, 7:38 pm)