summaryrefslogtreecommitdiff
path: root/lib/kobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kobject.c')
-rw-r--r--lib/kobject.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index 2430e2be81e3..5e8d1ed70716 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -349,16 +349,16 @@ int kobject_set_name(struct kobject * kobj, const char * fmt, ...)
/*
* Need more space? Allocate it and try again
*/
- name = kmalloc(need,GFP_KERNEL);
+ limit = need + 1;
+ name = kmalloc(limit,GFP_KERNEL);
if (!name) {
error = -ENOMEM;
goto Done;
}
- limit = need;
need = vsnprintf(name,limit,fmt,args);
/* Still? Give up. */
- if (need > limit) {
+ if (need >= limit) {
kfree(name);
error = -EFAULT;
goto Done;