Re: [PATCH] Driver Core patches for 2.6.6
From: Greg KH
Date: Fri May 14 2004 - 21:06:55 EST
ChangeSet 1.1587.5.25, 2004/05/11 16:31:46-07:00, maneesh@xxxxxxxxxx
[PATCH] kobject_set_name - error handling
1) kobject_set_name-cleanup-01.patch
This patch corrects the following by checking the reutrn code from
kobject_set_name().
bus_add_driver()
bus_register()
sys_dev_register()
o The following patch cleansup the kobject_set_name() users. Basically checking
return code from kobject_set_name(). There can be error returns like -ENOMEM
or -EFAULT from kobject_set_name() if the name length exceeds KOBJ_NAME_LEN.
drivers/base/bus.c | 11 +++++++++--
drivers/base/sys.c | 5 ++++-
2 files changed, 13 insertions(+), 3 deletions(-)
diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
--- a/drivers/base/bus.c Fri May 14 15:56:41 2004
+++ b/drivers/base/bus.c Fri May 14 15:56:41 2004
@@ -451,7 +451,11 @@
if (bus) {
pr_debug("bus %s: add driver %s\n",bus->name,drv->name);
- kobject_set_name(&drv->kobj,drv->name);
+ error = kobject_set_name(&drv->kobj,drv->name);
+ if (error) {
+ put_bus(bus);
+ return error;
+ }
drv->kobj.kset = &bus->drivers;
if ((error = kobject_register(&drv->kobj))) {
put_bus(bus);
@@ -557,7 +561,10 @@
{
int retval;
- kobject_set_name(&bus->subsys.kset.kobj,bus->name);
+ retval = kobject_set_name(&bus->subsys.kset.kobj,bus->name);
+ if (retval)
+ goto out;
+
subsys_set_kset(bus,bus_subsys);
retval = subsystem_register(&bus->subsys);
if (retval)
diff -Nru a/drivers/base/sys.c b/drivers/base/sys.c
--- a/drivers/base/sys.c Fri May 14 15:56:41 2004
+++ b/drivers/base/sys.c Fri May 14 15:56:41 2004
@@ -180,8 +180,11 @@
/* But make sure we point to the right type for sysfs translation */
sysdev->kobj.ktype = &ktype_sysdev;
- kobject_set_name(&sysdev->kobj,"%s%d",
+ error = kobject_set_name(&sysdev->kobj,"%s%d",
kobject_name(&cls->kset.kobj),sysdev->id);
+ if (error)
+ return error;
+
pr_debug("Registering sys device '%s'\n",kobject_name(&sysdev->kobj));
/* Register the object */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/