From: Xie XiuQi <[email protected]>

[ Upstream commit 07e9a6f538cbeecaf5c55b6f2991416f873cdcbd ]

Need to free "str" before return when asprintf() failed to avoid memory
leak.

Signed-off-by: Xie XiuQi <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Hongbo Yao <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Li Bin <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
 tools/perf/util/sort.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 46daa22b86e3b..85ff4f68adc00 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2690,7 +2690,7 @@ static char *prefix_if_not_in(const char *pre, char *str)
                return str;
 
        if (asprintf(&n, "%s,%s", pre, str) < 0)
-               return NULL;
+               n = NULL;
 
        free(str);
        return n;
-- 
2.25.1

Reply via email to