lkml.org 
[lkml]   [2019]   [Oct]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2] perf kmem: Fix memory leak in compact_gfp_flags()
Em Wed, Oct 16, 2019 at 09:26:50PM +0800, Yunfeng Ye escreveu:
> The memory @orig_flags is allocated by strdup(), it is freed on the
> normal path, but leak to free on the error path.
>
> Fix this by adding free(orig_flags) on the error path.
>
> Fixes: 0e11115644b3 ("perf kmem: Print gfp flags in human readable string")
> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
> ---
> v1 -> v2:
> - add "Fixes:" message

No need for that, I did it already, just next time look for when the
problem you fixed was introduced, that way the various bots out there
can pick this up for backports, i.e. your fix has a higher chance of
being beneficial to more systems.

- Arnaldo

> tools/perf/builtin-kmem.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
> index 1e61e353f579..9661671cc26e 100644
> --- a/tools/perf/builtin-kmem.c
> +++ b/tools/perf/builtin-kmem.c
> @@ -691,6 +691,7 @@ static char *compact_gfp_flags(char *gfp_flags)
> new = realloc(new_flags, len + strlen(cpt) + 2);
> if (new == NULL) {
> free(new_flags);
> + free(orig_flags);
> return NULL;
> }
>
> --
> 2.7.4.3

--

- Arnaldo

\
 
 \ /
  Last update: 2019-10-16 16:07    [W:0.038 / U:7.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site