login
Header Space

 
 

[PATCH 04/11] driver core: warn about duplicate driver names on the same bus

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Cc: Stas Sergeev <stsp@...>, Greg Kroah-Hartman <gregkh@...>
Date: Wednesday, April 30, 2008 - 7:57 pm

From: Stas Sergeev <stsp@aknet.ru>

Currently an attempt to register multiple
drivers with the same name causes the
stack trace with some cryptic error message.
The attached patch adds the necessary check
and the clear error message.

Signed-off-by: Stas Sergeev <stsp@aknet.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/base/driver.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 9a6537f..2ef5acf 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -217,12 +217,22 @@ static void driver_remove_groups(struct device_driver *drv,
 int driver_register(struct device_driver *drv)
 {
 	int ret;
+	struct device_driver *other;
 
 	if ((drv->bus->probe && drv->probe) ||
 	    (drv->bus->remove && drv->remove) ||
 	    (drv->bus->shutdown && drv->shutdown))
 		printk(KERN_WARNING "Driver '%s' needs updating - please use "
 			"bus_type methods\n", drv->name);
+
+	other = driver_find(drv->name, drv->bus);
+	if (other) {
+		put_driver(other);
+		printk(KERN_ERR "Error: Driver '%s' is already registered, "
+			"aborting...\n", drv->name);
+		return -EEXIST;
+	}
+
 	ret = bus_add_driver(drv);
 	if (ret)
 		return ret;
-- 
1.5.5.1

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

Messages in current thread:
[PATCH 11/11] klist: fix coding style errors in klist.h and ..., Greg Kroah-Hartman, (Wed Apr 30, 7:57 pm)
[PATCH 10/11] driver core: remove no longer used "struct cla..., Greg Kroah-Hartman, (Wed Apr 30, 7:57 pm)
[PATCH 09/11] pcmcia: remove pccard_sysfs_interface warnings, Greg Kroah-Hartman, (Wed Apr 30, 7:57 pm)
[PATCH 08/11] devres: support addresses greater than an unsi..., Greg Kroah-Hartman, (Wed Apr 30, 7:57 pm)
[PATCH 07/11] kobject: do not copy vargs, just pass them aro..., Greg Kroah-Hartman, (Wed Apr 30, 7:57 pm)
[PATCH 06/11] sysfs: sysfs_update_group stub for CONFIG_SYSF..., Greg Kroah-Hartman, (Wed Apr 30, 7:57 pm)
[PATCH 05/11] DEBUGFS: Correct location of debugfs API docum..., Greg Kroah-Hartman, (Wed Apr 30, 7:57 pm)
[PATCH 04/11] driver core: warn about duplicate driver names..., Greg Kroah-Hartman, (Wed Apr 30, 7:57 pm)
[PATCH 03/11] klist: implement klist_add_{after|before}(), Greg Kroah-Hartman, (Wed Apr 30, 7:57 pm)
[PATCH 02/11] klist: implement KLIST_INIT() and DEFINE_KLIST(), Greg Kroah-Hartman, (Wed Apr 30, 7:57 pm)
[PATCH 01/11] sysfs: Disallow truncation of files in sysfs, Greg Kroah-Hartman, (Wed Apr 30, 7:57 pm)
speck-geostationary