Commit 20629147 authored by Linus Torvalds's avatar Linus Torvalds

Make driver model use 'strlcpy()' to make sure that all

names are NUL-terminated

Noted by Ben Collins.
parent 0297761d
...@@ -431,7 +431,7 @@ int bus_add_driver(struct device_driver * drv) ...@@ -431,7 +431,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);
strncpy(drv->kobj.name,drv->name,KOBJ_NAME_LEN); strlcpy(drv->kobj.name,drv->name,KOBJ_NAME_LEN);
drv->kobj.kset = &bus->drivers; drv->kobj.kset = &bus->drivers;
if ((error = kobject_register(&drv->kobj))) { if ((error = kobject_register(&drv->kobj))) {
...@@ -540,7 +540,7 @@ struct bus_type * find_bus(char * name) ...@@ -540,7 +540,7 @@ struct bus_type * find_bus(char * name)
*/ */
int bus_register(struct bus_type * bus) int bus_register(struct bus_type * bus)
{ {
strncpy(bus->subsys.kset.kobj.name,bus->name,KOBJ_NAME_LEN); strlcpy(bus->subsys.kset.kobj.name,bus->name,KOBJ_NAME_LEN);
subsys_set_kset(bus,bus_subsys); subsys_set_kset(bus,bus_subsys);
subsystem_register(&bus->subsys); subsystem_register(&bus->subsys);
......
...@@ -88,7 +88,7 @@ int class_register(struct class * cls) ...@@ -88,7 +88,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);
strncpy(cls->subsys.kset.kobj.name,cls->name,KOBJ_NAME_LEN); strlcpy(cls->subsys.kset.kobj.name,cls->name,KOBJ_NAME_LEN);
subsys_set_kset(cls,class_subsys); subsys_set_kset(cls,class_subsys);
subsystem_register(&cls->subsys); subsystem_register(&cls->subsys);
...@@ -258,7 +258,7 @@ int class_device_add(struct class_device *class_dev) ...@@ -258,7 +258,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. */
strncpy(class_dev->kobj.name, class_dev->class_id, KOBJ_NAME_LEN); strlcpy(class_dev->kobj.name, class_dev->class_id, KOBJ_NAME_LEN);
kobj_set_kset_s(class_dev, class_obj_subsys); kobj_set_kset_s(class_dev, class_obj_subsys);
if (parent) if (parent)
class_dev->kobj.parent = &parent->subsys.kset.kobj; class_dev->kobj.parent = &parent->subsys.kset.kobj;
......
...@@ -211,7 +211,7 @@ int device_add(struct device *dev) ...@@ -211,7 +211,7 @@ int device_add(struct device *dev)
dev->bus_id, dev->name); dev->bus_id, dev->name);
/* first, register with generic layer. */ /* first, register with generic layer. */
strncpy(dev->kobj.name,dev->bus_id,KOBJ_NAME_LEN); strlcpy(dev->kobj.name,dev->bus_id,KOBJ_NAME_LEN);
if (parent) if (parent)
dev->kobj.parent = &parent->kobj; dev->kobj.parent = &parent->kobj;
......
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