public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kobject: name reference should not be lost when lack of memory error happens
@ 2010-10-07 10:32 Roman Tereshonkov
  2010-10-07 17:53 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Roman Tereshonkov @ 2010-10-07 10:32 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, Roman Tereshonkov

If lack of memory error happens we must restore the old kobject name reference

Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com>
---
 lib/kobject.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index f07c572..c5cb117 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, '/')))
-- 
1.7.0.4


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

end of thread, other threads:[~2010-10-09 18:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-07 10:32 [PATCH] kobject: name reference should not be lost when lack of memory error happens Roman Tereshonkov
2010-10-07 17:53 ` Greg KH
2010-10-09 14:32   ` Kay Sievers
2010-10-09 18:32     ` Greg KH

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