lkml.org 
[lkml]   [2009]   [May]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH 1/3] kobject : kobject_set_name_vargs leak fix
From
kobject_set_name_vargs will leak the old_name when return -ENOMEM,
move the kfree(old_name) before the return path.

Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
---
lib/kobject.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff -uprN linux.old/lib/kobject.c linux.new/lib/kobject.c
--- linux.old/lib/kobject.c 2009-05-11 13:59:01.000000000 +0800
+++ linux.new/lib/kobject.c 2009-05-11 13:59:34.000000000 +0800
@@ -221,6 +221,7 @@ int kobject_set_name_vargs(struct kobjec
if (kobj->name && !fmt)
return 0;

+ kfree(old_name);
kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
if (!kobj->name)
return -ENOMEM;
@@ -229,7 +230,6 @@ int kobject_set_name_vargs(struct kobjec
while ((s = strchr(kobj->name, '/')))
s[0] = '!';

- kfree(old_name);
return 0;
}

\
 
 \ /
  Last update: 2009-05-11 08:19    [W:0.502 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site