Skip to content

Commit

Permalink
[PATCH] kobject_add() must have a valid name in order to succeed.
Browse files Browse the repository at this point in the history
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: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Greg Kroah-Hartman committed Feb 6, 2006
1 parent e3f749c commit c171fef
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/kobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ int kobject_add(struct kobject * kobj)
return -ENOENT;
if (!kobj->k_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);

pr_debug("kobject %s: registering. parent: %s, set: %s\n",
Expand Down

0 comments on commit c171fef

Please sign in to comment.