perf hists: Add extra integrity checks to fmt_free()
authorJiri Olsa <jolsa@kernel.org>
Fri, 13 Oct 2017 08:37:29 +0000 (10:37 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 13 Oct 2017 19:43:42 +0000 (16:43 -0300)
Make sure the struct perf_hpp_fmt is properly unhooked before we free
it.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Changbin Du <changbin.du@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20171013083736.15037-3-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/ui/hist.c

index 6ee6b36bbc763c7546ec2f81379b31b503c577dd..db79017a6e56fc1b836fbbeb178e9eb7c57a7a89 100644 (file)
@@ -606,6 +606,13 @@ next:
 
 static void fmt_free(struct perf_hpp_fmt *fmt)
 {
+       /*
+        * At this point fmt should be completely
+        * unhooked, if not it's a bug.
+        */
+       BUG_ON(!list_empty(&fmt->list));
+       BUG_ON(!list_empty(&fmt->sort_list));
+
        if (fmt->free)
                fmt->free(fmt);
 }