Commit b365b3daf2a9e2a8b002ea9fef877af1c71513fd

Authored by Chuck Ebbert
Committed by Greg Kroah-Hartman
1 parent c171fef5c8

[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>

Showing 1 changed file with 4 additions and 0 deletions Side-by-side Diff

... ... @@ -72,6 +72,8 @@
72 72 * Add 1 to strlen for leading '/' of each level.
73 73 */
74 74 do {
  75 + if (kobject_name(parent) == NULL)
  76 + return 0;
75 77 length += strlen(kobject_name(parent)) + 1;
76 78 parent = parent->parent;
77 79 } while (parent);
... ... @@ -107,6 +109,8 @@
107 109 int len;
108 110  
109 111 len = get_kobj_path_length(kobj);
  112 + if (len == 0)
  113 + return NULL;
110 114 path = kmalloc(len, gfp_mask);
111 115 if (!path)
112 116 return NULL;