PATCH -- kobject_set_name() doesn't allocate enough space

From: Linda Xie
Date: Tue Dec 16 2003 - 15:12:22 EST



Hi All,

The sapce allocated in kobject_set_name() is 1 byte less than it should be. The Attached patch fixes this bug.


Comments are welcome.

Thanks,



Linda Xie
IBM Linux Technology Center



diff -Nru a/lib/kobject.c b/lib/kobject.c
--- a/lib/kobject.c Sun Dec 14 21:19:29 2003
+++ b/lib/kobject.c Sun Dec 14 21:19:29 2003
@@ -344,12 +344,12 @@
/*
* 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. */

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/