aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/core.c3
-rw-r--r--lib/kobject.c3
2 files changed, 5 insertions, 1 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index d230ff4b3eec..4aa527b8a913 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -891,7 +891,8 @@ int device_add(struct device *dev)
891 set_dev_node(dev, dev_to_node(parent)); 891 set_dev_node(dev, dev_to_node(parent));
892 892
893 /* first, register with generic layer. */ 893 /* first, register with generic layer. */
894 error = kobject_add(&dev->kobj, dev->kobj.parent, "%s", dev_name(dev)); 894 /* we require the name to be set before, and pass NULL */
895 error = kobject_add(&dev->kobj, dev->kobj.parent, NULL);
895 if (error) 896 if (error)
896 goto Error; 897 goto Error;
897 898
diff --git a/lib/kobject.c b/lib/kobject.c
index a6dec32f2ddd..bacf6fe4f7a0 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -218,6 +218,9 @@ int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
218 const char *old_name = kobj->name; 218 const char *old_name = kobj->name;
219 char *s; 219 char *s;
220 220
221 if (kobj->name && !fmt)
222 return 0;
223
221 kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs); 224 kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
222 if (!kobj->name) 225 if (!kobj->name)
223 return -ENOMEM; 226 return -ENOMEM;