diff options
-rw-r--r-- | lib/kobject.c | 4 |
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; |