aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kobject.c
diff options
context:
space:
mode:
authorChuck Ebbert <76306.1226@compuserve.com>2006-01-12 20:02:00 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-02-06 15:17:17 -0500
commitb365b3daf2a9e2a8b002ea9fef877af1c71513fd (patch)
treedcd673d830b61ee37ab433af60c0f81ffaa86779 /lib/kobject.c
parentc171fef5c8566cf5f57877e7832fa696ecdf5228 (diff)
[PATCH] kobject: don't oops on null kobject.name
kobject_get_path() will oops if one of the component names is NULL. Fix that by returning NULL instead of oopsing. Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib/kobject.c')
-rw-r--r--lib/kobject.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index fe4ae36ce960..efe67fa96a71 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -72,6 +72,8 @@ static int get_kobj_path_length(struct kobject *kobj)
72 * Add 1 to strlen for leading '/' of each level. 72 * Add 1 to strlen for leading '/' of each level.
73 */ 73 */
74 do { 74 do {
75 if (kobject_name(parent) == NULL)
76 return 0;
75 length += strlen(kobject_name(parent)) + 1; 77 length += strlen(kobject_name(parent)) + 1;
76 parent = parent->parent; 78 parent = parent->parent;
77 } while (parent); 79 } while (parent);
@@ -107,6 +109,8 @@ char *kobject_get_path(struct kobject *kobj, gfp_t gfp_mask)
107 int len; 109 int len;
108 110
109 len = get_kobj_path_length(kobj); 111 len = get_kobj_path_length(kobj);
112 if (len == 0)
113 return NULL;
110 path = kmalloc(len, gfp_mask); 114 path = kmalloc(len, gfp_mask);
111 if (!path) 115 if (!path)
112 return NULL; 116 return NULL;