public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf: add sanity check on addr in symbol__inc_addr_samples()
@ 2012-02-09 10:30 Stephane Eranian
  2012-02-09 14:48 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 7+ messages in thread
From: Stephane Eranian @ 2012-02-09 10:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: acme, peterz, mingo


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;

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

end of thread, other threads:[~2012-02-10 14:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-09 10:30 [PATCH] perf: add sanity check on addr in symbol__inc_addr_samples() Stephane Eranian
2012-02-09 14:48 ` Arnaldo Carvalho de Melo
2012-02-09 14:53   ` Stephane Eranian
2012-02-09 15:06     ` Sorin Dumitru
2012-02-10 14:20       ` Arnaldo Carvalho de Melo
2012-02-10 13:46     ` Arnaldo Carvalho de Melo
2012-02-10 13:49       ` Stephane Eranian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox