lkml.org 
[lkml]   [2009]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] kobject_set_name: free old_name in case of ENOMEM

If the memory allocation for the kobject's name fails we should free
the old_name since it is no longer accessible via kobj->name.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
---
lib/kobject.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Index: git.linux-2.6/lib/kobject.c
===================================================================
--- git.linux-2.6.orig/lib/kobject.c 2009-06-17 10:35:55.000000000 +0200
+++ git.linux-2.6/lib/kobject.c 2009-09-09 18:21:39.000000000 +0200
@@ -222,8 +222,10 @@ int kobject_set_name_vargs(struct kobjec
return 0;

kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
- if (!kobj->name)
+ if (!kobj->name) {
+ kfree(old_name);
return -ENOMEM;
+ }

/* ewww... some of these buggers have '/' in the name ... */
while ((s = strchr(kobj->name, '/')))

\
 
 \ /
  Last update: 2009-09-09 18:55    [W:0.036 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site