kobject_set_name: free old_name in case of ENOMEM
Subsystems (2)
PATCH 1/1 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 <[email protected]>
--- lib/kobject.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/kobject.c +3 -1
@@ -222,8 +222,10 @@ int kobject_set_name_vargs(struct kobjecreturn 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,'/' )))
Quoted 3 lines · Sebastian Ott
If the memory allocation for the kobject's name fails we should free the
old_namesince it is no longer accessible viakobj->name.
Hasn't this come up a bunch in the past, and we do not want to do this?
You might want to search the lkml archives for details...
thanks,
greg k-h