All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf: double free at function perf_hpp__reset_output_field
@ 2017-03-15  2:16 changbin.du
  2017-03-27  6:22 ` [PATCH v2] perf: fix " changbin.du
  0 siblings, 1 reply; 20+ messages in thread
From: changbin.du @ 2017-03-15  2:16 UTC (permalink / raw)
  To: peterz, mingo, acme; +Cc: linux-kernel, Changbin Du, Changbin Du

From: Changbin Du <changbin.du@gmail.com>

Some perf_hpp_fmt both registered at field and sort list. For such
instance, we only can free it when removed from the both lists.

Signed-off-by: Changbin Du <changbin.du@gmail.com>
Signed-off-by: Changbin Du <changbin.du@intel.com>
---
 tools/perf/ui/hist.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 5d632dc..f94b301 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -609,20 +609,25 @@ static void fmt_free(struct perf_hpp_fmt *fmt)
 
 void perf_hpp__reset_output_field(struct perf_hpp_list *list)
 {
-	struct perf_hpp_fmt *fmt, *tmp;
+	struct perf_hpp_fmt *field_fmt, *sort_fmt, *tmp1, *tmp2;
 
 	/* reset output fields */
-	perf_hpp_list__for_each_format_safe(list, fmt, tmp) {
-		list_del_init(&fmt->list);
-		list_del_init(&fmt->sort_list);
-		fmt_free(fmt);
+	perf_hpp_list__for_each_format_safe(list, field_fmt, tmp1) {
+		list_del_init(&field_fmt->list);
+		/* reset sort keys */
+		perf_hpp_list__for_each_sort_list_safe(list, sort_fmt, tmp2) {
+			if (field_fmt == sort_fmt) {
+				list_del_init(&field_fmt->sort_list);
+				break;
+			}
+		}
+		fmt_free(field_fmt);
 	}
 
-	/* reset sort keys */
-	perf_hpp_list__for_each_sort_list_safe(list, fmt, tmp) {
-		list_del_init(&fmt->list);
-		list_del_init(&fmt->sort_list);
-		fmt_free(fmt);
+	/* reset remaining sort keys */
+	perf_hpp_list__for_each_sort_list_safe(list, sort_fmt, tmp1) {
+		list_del_init(&sort_fmt->sort_list);
+		fmt_free(sort_fmt);
 	}
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2017-05-31  7:19 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-15  2:16 [PATCH] perf: double free at function perf_hpp__reset_output_field changbin.du
2017-03-27  6:22 ` [PATCH v2] perf: fix " changbin.du
2017-04-04 15:19   ` Arnaldo Carvalho de Melo
2017-04-04 15:34     ` Namhyung Kim
2017-04-04 15:51       ` Arnaldo Carvalho de Melo
2017-04-05  2:44         ` Du, Changbin
2017-04-09 17:05           ` Jiri Olsa
2017-04-10  2:13             ` Du, Changbin
2017-04-10  8:39     ` Jiri Olsa
2017-04-10 10:21       ` Du, Changbin
2017-04-10 11:33         ` Jiri Olsa
2017-04-11  3:06           ` Du, Changbin
2017-04-11  7:35             ` Jiri Olsa
2017-04-11  8:25               ` Du, Changbin
2017-04-11 10:05                 ` Jiri Olsa
2017-04-11 10:13                   ` Du, Changbin
2017-04-11 10:32                     ` Jiri Olsa
2017-04-12  1:48                       ` Du, Changbin
2017-05-31  7:05                         ` Du, Changbin
2017-05-31  7:19                           ` Jiri Olsa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.