From: Greg Kroah-Hartman Date: Fri, 20 Jan 2006 22:08:59 +0000 (-0800) Subject: [PATCH] kobject_add() must have a valid name in order to succeed. X-Git-Tag: v2.6.16-rc3~97^2~9 X-Git-Url: http://www.pilppa.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=c171fef5c8566cf5f57877e7832fa696ecdf5228;p=linux-2.6-omap-h63xx.git [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: Greg Kroah-Hartman --- diff --git a/lib/kobject.c b/lib/kobject.c index 7a0e6809490..fe4ae36ce96 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -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",