Message ID | 1454680939-24963-2-git-send-email-wangnan0@huawei.com |
---|---|
State | New |
Headers | show |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 813d9b2..e8b2d85 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -2072,8 +2072,15 @@ void parse_events__free_terms(struct list_head *terms) { struct parse_events_term *term, *h; - list_for_each_entry_safe(term, h, terms, list) + if (!terms) + return; + + list_for_each_entry_safe(term, h, terms, list) { + list_del(&term->list); free(term); + } + + free(terms); } void parse_events_evlist_error(struct parse_events_evlist *data,
We expect parse_events__free_terms() destory the full config term list. However, current code leaves the list header unclean, and points to a invalidated linked list. Signed-off-by: Wang Nan <wangnan0@huawei.com> Cc: He Kuang <hekuang@huawei.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Zefan Li <lizefan@huawei.com> Cc: pi3orama@163.com --- tools/perf/util/parse-events.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 1.8.3.4