Skip to content

Commit 1abecfc

Browse files
yeyunfeng-devacmel
authored andcommitted
perf kmem: Fix memory leak in compact_gfp_flags()
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: 0e11115 ("perf kmem: Print gfp flags in human readable string") Signed-off-by: Yunfeng Ye <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Feilong Lin <[email protected]> Cc: Hu Shiyuan <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 5eca137 commit 1abecfc

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

tools/perf/builtin-kmem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ static char *compact_gfp_flags(char *gfp_flags)
691691
new = realloc(new_flags, len + strlen(cpt) + 2);
692692
if (new == NULL) {
693693
free(new_flags);
694+
free(orig_flags);
694695
return NULL;
695696
}
696697

0 commit comments

Comments
 (0)