public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kobject: Fix kobject_set_name_vargs()
@ 2010-03-11 20:50 Eric Dumazet
  2010-03-12  4:15 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2010-03-11 20:50 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

In case of kvasprintf() failure, we can leak old kobject name.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
diff --git a/lib/kobject.c b/lib/kobject.c
index 8115eb1..1247c57 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -222,8 +222,10 @@ int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
 		return 0;
 
 	kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
-	if (!kobj->name)
+	if (!kobj->name) {
+		kobj->name = old_name;
 		return -ENOMEM;
+	}
 
 	/* ewww... some of these buggers have '/' in the name ... */
 	while ((s = strchr(kobj->name, '/')))



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

end of thread, other threads:[~2010-03-12  4:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-11 20:50 [PATCH] kobject: Fix kobject_set_name_vargs() Eric Dumazet
2010-03-12  4:15 ` Greg KH
2010-03-12  4:39   ` Kay Sievers
2010-03-12  4:46     ` Kay Sievers

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