public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* PATCH -- kobject_set_name() doesn't allocate enough space
@ 2003-12-16 20:15 Linda Xie
  2003-12-16 20:44 ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: Linda Xie @ 2003-12-16 20:15 UTC (permalink / raw)
  To: linux-kernel, Greg KH; +Cc: scheel, wortman


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. */


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-12-16 23:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-16 20:15 PATCH -- kobject_set_name() doesn't allocate enough space Linda Xie
2003-12-16 20:44 ` Linus Torvalds
2003-12-16 23:24   ` Linda Xie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox