diff options
author | Marcin Nowakowski <marcin.nowakowski@imgtec.com> | 2017-06-08 09:20:32 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2017-06-08 09:42:05 -0400 |
commit | 698b851073ddf5a894910d63ca04605e0473414e (patch) | |
tree | 5596fd6ed960744d301f1af6329942e6684711ee | |
parent | 87051ec120bb9abd9e57aecf2569c00d587b6f33 (diff) |
MIPS: kprobes: flush_insn_slot should flush only if probe initialised
When ftrace is used with kprobes, it is possible for a kprobe to contain
an invalid location (ie. only initialised to 0 and not to a specific
location in the code). Trying to perform a cache flush on such location
leads to a crash r4k_flush_icache_range().
Fixes: c1bf207d6ee1 ("MIPS: kprobe: Add support.")
Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/16296/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/include/asm/kprobes.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/mips/include/asm/kprobes.h b/arch/mips/include/asm/kprobes.h index 291846d9ba83..ad1a99948f27 100644 --- a/arch/mips/include/asm/kprobes.h +++ b/arch/mips/include/asm/kprobes.h | |||
@@ -43,7 +43,8 @@ typedef union mips_instruction kprobe_opcode_t; | |||
43 | 43 | ||
44 | #define flush_insn_slot(p) \ | 44 | #define flush_insn_slot(p) \ |
45 | do { \ | 45 | do { \ |
46 | flush_icache_range((unsigned long)p->addr, \ | 46 | if (p->addr) \ |
47 | flush_icache_range((unsigned long)p->addr, \ | ||
47 | (unsigned long)p->addr + \ | 48 | (unsigned long)p->addr + \ |
48 | (MAX_INSN_SIZE * sizeof(kprobe_opcode_t))); \ | 49 | (MAX_INSN_SIZE * sizeof(kprobe_opcode_t))); \ |
49 | } while (0) | 50 | } while (0) |