[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20161021001706.GB23970@krava>
Date: Fri, 21 Oct 2016 02:17:06 +0200
From: Jiri Olsa <jolsa@...hat.com>
To: Kim Phillips <kim.phillips@....com>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>,
Ingo Molnar <mingo@...nel.org>, linux-kernel@...r.kernel.org,
Linux Weekly News <lwn@....net>,
Andi Kleen <andi@...stfloor.org>,
David Ahern <dsahern@...il.com>,
Don Zickus <dzickus@...hat.com>, Jiri Olsa <jolsa@...nel.org>,
Joe Mario <jmario@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Arnaldo Carvalho de Melo <acme@...hat.com>
Subject: [PATCH] perf c2c report: Properly check data presence in rb_tree loop
On Thu, Oct 20, 2016 at 06:02:24PM -0500, Kim Phillips wrote:
SNIP
> (gdb) bt
> #0 c2c_browser__update_nr_entries (hb=<optimized out>, hb=<optimized out>) at builtin-c2c.c:2142
> #1 perf_c2c__hists_browse (hists=0x8b2d90 <c2c+240>) at builtin-c2c.c:2287
> #2 perf_c2c_display (session=0x205b1a0) at builtin-c2c.c:2316
> #3 perf_c2c__report (argv=<optimized out>, argc=<optimized out>) at builtin-c2c.c:2621
> #4 cmd_c2c (argc=<optimized out>, argv=<optimized out>, prefix=<optimized out>) at builtin-c2c.c:2748
> #5 0x000000000048df61 in run_builtin (p=p@...ry=0x8be168 <commands+72>, argc=argc@...ry=2, argv=argv@...ry=0x7fffffffddb0)
> at perf.c:358
> #6 0x00000000004249b6 in handle_internal_command (argv=0x7fffffffddb0, argc=2) at perf.c:420
> #7 run_argv (argv=0x7fffffffdb40, argcp=0x7fffffffdb4c) at perf.c:466
> #8 main (argc=2, argv=0x7fffffffddb0) at perf.c:610
> (gdb)
>
> All the above work fine when run under sudo.
ugh, stupid mistake.. attached patch fixes that for me
thanks,
jirka
---
Kim reported crash when there's no data stored. In this case
the TUI code crashes in c2c_browser__update_nr_entries, because
we dont check the initial rb_tree node for NULL.
Adding the missing check.
Reported-by: Kim Phillips <kim.phillips@....com>
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
tools/perf/builtin-c2c.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index dc4f0636dfa1..c6d0dda594d9 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -2135,14 +2135,14 @@ static void c2c_browser__update_nr_entries(struct hist_browser *hb)
u64 nr_entries = 0;
struct rb_node *nd = rb_first(&hb->hists->entries);
- do {
+ while (nd) {
struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node);
if (!he->filtered)
nr_entries++;
nd = rb_next(nd);
- } while (nd);
+ }
hb->nr_non_filtered_entries = nr_entries;
}
--
2.7.4
Powered by blists - more mailing lists