提交 c171fef5 编写于 作者: G Greg Kroah-Hartman

[PATCH] kobject_add() must have a valid name in order to succeed.

So we might as well check to verify this, and let the user know that
something is wrong if they didn't do it correctly, instead of oopsing
later on in kobject_get_name() or somewhere else.
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 e3f749c4
...@@ -162,6 +162,11 @@ int kobject_add(struct kobject * kobj) ...@@ -162,6 +162,11 @@ int kobject_add(struct kobject * kobj)
return -ENOENT; return -ENOENT;
if (!kobj->k_name) if (!kobj->k_name)
kobj->k_name = kobj->name; kobj->k_name = kobj->name;
if (!kobj->k_name) {
pr_debug("kobject attempted to be registered with no name!\n");
WARN_ON(1);
return -EINVAL;
}
parent = kobject_get(kobj->parent); parent = kobject_get(kobj->parent);
pr_debug("kobject %s: registering. parent: %s, set: %s\n", pr_debug("kobject %s: registering. parent: %s, set: %s\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册