s390: add error handling to perf_callchain_kernel
authorIlya Leoshkevich <iii@linux.ibm.com>
Wed, 30 Oct 2019 13:20:32 +0000 (14:20 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Thu, 31 Oct 2019 16:20:54 +0000 (17:20 +0100)
perf_callchain_kernel stops neither when it encounters a garbage
address, nor when it runs out of space. Fix both issues using x86
version as an inspiration.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/kernel/perf_event.c

index fcb6c2e..1e75cc9 100644 (file)
@@ -224,9 +224,13 @@ void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
                           struct pt_regs *regs)
 {
        struct unwind_state state;
+       unsigned long addr;
 
-       unwind_for_each_frame(&state, current, regs, 0)
-               perf_callchain_store(entry, state.ip);
+       unwind_for_each_frame(&state, current, regs, 0) {
+               addr = unwind_get_return_address(&state);
+               if (!addr || perf_callchain_store(entry, addr))
+                       return;
+       }
 }
 
 /* Perf definitions for PMU event attributes in sysfs */