[PATCH] kobject_set_name: free old_name in case of ENOMEM
From: Sebastian Ott
Date: Wed Sep 09 2009 - 12:53:47 EST
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@xxxxxxxxxxxxxxxxxx>
---
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, '/')))
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/