Subject: [PATCH 4.9 005/116] perf annotate: Dont throw error for zero length symbols

From: Greg Kroah-Hartman <[email-masked]>
Date: Fri, 6 Jan 2017 22:42:47 +0100

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ravi Bangoria <[email-masked]>

commit edee44be59190bf22d5c6e521f3852b7ff16862f upstream.

'perf report --tui' exits with error when it finds a sample of zero
length symbol (i.e. addr == sym->start == sym->end). Actually these are
valid samples. Don't exit TUI and show report with such symbols.

Reported-and-Tested-by: Anton Blanchard <[email-masked]>
Link: https://lkml.org/lkml/2016/10/8/189
Signed-off-by: Ravi Bangoria <[email-masked]>
Cc: Alexander Shishkin <[email-masked]>
Cc: Benjamin Herrenschmidt <[email-masked]>
Cc: Chris Riyder <[email-masked]>
Cc: [email-masked]
Cc: Masami Hiramatsu <[email-masked]>
Cc: Michael Ellerman <[email-masked]>
Cc: Nicholas Piggin <[email-masked]>
Cc: Paul Mackerras <[email-masked]>
Cc: Peter Zijlstra <[email-masked]>
Link: http://lkml.kernel.org/r/[email-masked]
Signed-off-by: Arnaldo Carvalho de Melo <[email-masked]>
Signed-off-by: Greg Kroah-Hartman <[email-masked]>

---
 tools/perf/util/annotate.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -593,7 +593,8 @@ static int __symbol__inc_addr_samples(st
 
 	pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map->unmap_ip(map, addr));
 
-	if (addr < sym->start || addr >= sym->end) {
+	if ((addr < sym->start || addr >= sym->end) &&
+	    (addr != sym->end || sym->start != sym->end)) {
 		pr_debug("%s(%d): ERANGE! sym->name=%s, start=%#" PRIx64 ", addr=%#" PRIx64 ", end=%#" PRIx64 "\n",
 		       __func__, __LINE__, sym->name, sym->start, addr, sym->end);
 		return -ERANGE;