Commit ab7f7331 authored by Maneesh Soni's avatar Maneesh Soni Committed by Greg Kroah-Hartman

[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.
parent e15f75b5
......@@ -451,7 +451,11 @@ int bus_add_driver(struct device_driver * drv)
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 bus_register(struct bus_type * bus)
{
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)
......
......@@ -180,8 +180,11 @@ int sysdev_register(struct sys_device * sysdev)
/* 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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment