[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200918020110.2063155-295-sashal@kernel.org>
Date: Thu, 17 Sep 2020 22:00:35 -0400
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: Xie XiuQi <xiexiuqi@...wei.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Hongbo Yao <yaohongbo@...wei.com>,
Jiri Olsa <jolsa@...hat.com>, Li Bin <huawei.libin@...wei.com>,
Mark Rutland <mark.rutland@....com>,
Namhyung Kim <namhyung@...nel.org>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH AUTOSEL 5.4 295/330] perf util: Fix memory leak of prefix_if_not_in
From: Xie XiuQi <xiexiuqi@...wei.com>
[ Upstream commit 07e9a6f538cbeecaf5c55b6f2991416f873cdcbd ]
Need to free "str" before return when asprintf() failed to avoid memory
leak.
Signed-off-by: Xie XiuQi <xiexiuqi@...wei.com>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Hongbo Yao <yaohongbo@...wei.com>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Li Bin <huawei.libin@...wei.com>
Cc: Mark Rutland <mark.rutland@....com>
Cc: Namhyung Kim <namhyung@...nel.org>
Link: http://lore.kernel.org/lkml/20200521133218.30150-4-liwei391@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
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 43d1d410854a3..4027906fd3e38 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -2788,7 +2788,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
Powered by blists - more mailing lists