lkml.org 
[lkml]   [2012]   [Feb]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] perf: add sanity check on addr in symbol__inc_addr_samples()

Check the value of addr against the bounds of the symbol.
This is needed given we compute an offset:
offset = addr - sym->start

And we don't want the offset to become negative.

Signed-off-by: Stephane Eranian <eranian@google.com>

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 011ed26..8248d80 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -64,7 +64,7 @@ int symbol__inc_addr_samples(struct symbol *sym, struct map *map,

pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map->unmap_ip(map, addr));

- if (addr >= sym->end)
+ if (addr >= sym->end || addr < sym->start)
return 0;

offset = addr - sym->start;

\
 
 \ /
  Last update: 2012-02-09 11:33    [W:0.292 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site