lkml.org 
[lkml]   [2009]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH] kobject_set_name_vargs memory leak
    Hello.
    I suppose this patch fixes memory leak in kobject.c
    Correct me if I'm wrong.
    Thanks.
    -----------

    Fix memory leak when kobject_set_name_vargs returns -ENOMEM.

    Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@mail.by>
    ---
    diff --git a/lib/kobject.c b/lib/kobject.c
    index b512b74..922cd8c 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) {
    + kfree(old_name);
    return -ENOMEM;
    + }

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

    \
     
     \ /
      Last update: 2009-06-26 16:39    [W:0.029 / U:30.816 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site