Commit dcde404f authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Greg Kroah-Hartman

[PATCH] avoid problems with kobject_set_name and name with %

kobject_set_name takes a printf style argument list. There are many
callers that pass only one string, if this string contained a '%' character
than bad things would happen.  The fix is simple.
Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent ba649f5b
...@@ -515,7 +515,7 @@ int bus_add_driver(struct device_driver * drv) ...@@ -515,7 +515,7 @@ int bus_add_driver(struct device_driver * drv)
if (bus) { if (bus) {
pr_debug("bus %s: add driver %s\n", bus->name, drv->name); pr_debug("bus %s: add driver %s\n", bus->name, drv->name);
error = kobject_set_name(&drv->kobj, drv->name); error = kobject_set_name(&drv->kobj, "%s", drv->name);
if (error) { if (error) {
put_bus(bus); put_bus(bus);
return error; return error;
...@@ -666,7 +666,7 @@ int bus_register(struct bus_type * bus) ...@@ -666,7 +666,7 @@ int bus_register(struct bus_type * bus)
{ {
int retval; int retval;
retval = kobject_set_name(&bus->subsys.kset.kobj, bus->name); retval = kobject_set_name(&bus->subsys.kset.kobj, "%s", bus->name);
if (retval) if (retval)
goto out; goto out;
......
...@@ -139,7 +139,7 @@ int class_register(struct class * cls) ...@@ -139,7 +139,7 @@ int class_register(struct class * cls)
INIT_LIST_HEAD(&cls->children); INIT_LIST_HEAD(&cls->children);
INIT_LIST_HEAD(&cls->interfaces); INIT_LIST_HEAD(&cls->interfaces);
error = kobject_set_name(&cls->subsys.kset.kobj, cls->name); error = kobject_set_name(&cls->subsys.kset.kobj, "%s", cls->name);
if (error) if (error)
return error; return error;
...@@ -368,7 +368,7 @@ int class_device_add(struct class_device *class_dev) ...@@ -368,7 +368,7 @@ int class_device_add(struct class_device *class_dev)
class_dev->class_id); class_dev->class_id);
/* first, register with generic layer. */ /* first, register with generic layer. */
kobject_set_name(&class_dev->kobj, class_dev->class_id); kobject_set_name(&class_dev->kobj, "%s", class_dev->class_id);
if (parent) if (parent)
class_dev->kobj.parent = &parent->subsys.kset.kobj; class_dev->kobj.parent = &parent->subsys.kset.kobj;
......
...@@ -221,7 +221,7 @@ int device_add(struct device *dev) ...@@ -221,7 +221,7 @@ int device_add(struct device *dev)
pr_debug("DEV: registering device: ID = '%s'\n", dev->bus_id); pr_debug("DEV: registering device: ID = '%s'\n", dev->bus_id);
/* first, register with generic layer. */ /* first, register with generic layer. */
kobject_set_name(&dev->kobj, dev->bus_id); kobject_set_name(&dev->kobj, "%s", dev->bus_id);
if (parent) if (parent)
dev->kobj.parent = &parent->kobj; dev->kobj.parent = &parent->kobj;
......
...@@ -640,7 +640,7 @@ efivar_create_sysfs_entry(unsigned long variable_name_size, ...@@ -640,7 +640,7 @@ efivar_create_sysfs_entry(unsigned long variable_name_size,
*(short_name + strlen(short_name)) = '-'; *(short_name + strlen(short_name)) = '-';
efi_guid_unparse(vendor_guid, short_name + strlen(short_name)); efi_guid_unparse(vendor_guid, short_name + strlen(short_name));
kobject_set_name(&new_efivar->kobj, short_name); kobject_set_name(&new_efivar->kobj, "%s", short_name);
kobj_set_kset_s(new_efivar, vars_subsys); kobj_set_kset_s(new_efivar, vars_subsys);
kobject_register(&new_efivar->kobj); kobject_register(&new_efivar->kobj);
......
...@@ -568,7 +568,7 @@ int pci_hp_register (struct hotplug_slot *slot) ...@@ -568,7 +568,7 @@ int pci_hp_register (struct hotplug_slot *slot)
if ((slot->info == NULL) || (slot->ops == NULL)) if ((slot->info == NULL) || (slot->ops == NULL))
return -EINVAL; return -EINVAL;
kobject_set_name(&slot->kobj, slot->name); kobject_set_name(&slot->kobj, "%s", slot->name);
kobj_set_kset_s(slot, pci_hotplug_slots_subsys); kobj_set_kset_s(slot, pci_hotplug_slots_subsys);
/* this can fail if we have already registered a slot with the same name */ /* this can fail if we have already registered a slot with the same name */
......
...@@ -181,7 +181,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name) ...@@ -181,7 +181,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
new_dentry = sysfs_get_dentry(parent, new_name); new_dentry = sysfs_get_dentry(parent, new_name);
if (!IS_ERR(new_dentry)) { if (!IS_ERR(new_dentry)) {
if (!new_dentry->d_inode) { if (!new_dentry->d_inode) {
error = kobject_set_name(kobj,new_name); error = kobject_set_name(kobj, "%s", new_name);
if (!error) if (!error)
d_move(kobj->dentry, new_dentry); d_move(kobj->dentry, new_dentry);
} }
......
...@@ -1120,7 +1120,7 @@ static int mod_sysfs_setup(struct module *mod, ...@@ -1120,7 +1120,7 @@ static int mod_sysfs_setup(struct module *mod,
return -ENOMEM; return -ENOMEM;
memset(&mod->mkobj->kobj, 0, sizeof(mod->mkobj->kobj)); memset(&mod->mkobj->kobj, 0, sizeof(mod->mkobj->kobj));
err = kobject_set_name(&mod->mkobj->kobj, mod->name); err = kobject_set_name(&mod->mkobj->kobj, "%s", mod->name);
if (err) if (err)
goto out; goto out;
kobj_set_kset_s(mod->mkobj, module_subsys); kobj_set_kset_s(mod->mkobj, module_subsys);
......
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