提交 ff9ac5df 编写于 作者: R Riccardo Mancini 提交者: Zheng Zengkai

perf data: Close all files in close_dir()

mainline inclusion
from mainline-5.14-rc2
commit d4b3eedc
category: bugfix
bugzilla: 171902 https://gitee.com/openeuler/kernel/issues/I4DDEL

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d4b3eedce151e63932ce4a00f1d0baa340a8b907

--------------------------------

When using 'perf report' in directory mode, the first file is not closed
on exit, causing a memory leak.

The problem is caused by the iterating variable never reaching 0.

Fixes: 14552063 ("perf data: Add perf_data__(create_dir|close_dir) functions")
Signed-off-by: NRiccardo Mancini <rickyman7@gmail.com>
Acked-by: NNamhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zhen Lei <thunder.leizhen@huawei.com>
Link: http://lore.kernel.org/lkml/20210716141122.858082-1-rickyman7@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: NZhang Jinhao <zhangjinhao2@huawei.com>
Reviewed-by: NYang Jihong <yangjihong1@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 495ff837
......@@ -20,7 +20,7 @@
static void close_dir(struct perf_data_file *files, int nr)
{
while (--nr >= 1) {
while (--nr >= 0) {
close(files[nr].fd);
zfree(&files[nr].path);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册