Skip to content

Commit 04dea5f

Browse files
Prasanna S PanchamukhiLinus Torvalds
authored andcommitted
[PATCH] Kprobes: Oops! in unregister_kprobe()
kernel oops! when unregister_kprobe() is called on a non-registered kprobe. This patch fixes the above problem by checking if the probe exists before unregistering. Signed-off-by: Prasanna S Panchamukhi <prasanna@in.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 0b9e2ca commit 04dea5f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎kernel/kprobes.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,17 @@ int register_kprobe(struct kprobe *p)
107107
void unregister_kprobe(struct kprobe *p)
108108
{
109109
unsigned long flags;
110-
arch_remove_kprobe(p);
111110
spin_lock_irqsave(&kprobe_lock, flags);
111+
if (!get_kprobe(p->addr)) {
112+
spin_unlock_irqrestore(&kprobe_lock, flags);
113+
return;
114+
}
112115
*p->addr = p->opcode;
113116
hlist_del(&p->hlist);
114117
flush_icache_range((unsigned long) p->addr,
115118
(unsigned long) p->addr + sizeof(kprobe_opcode_t));
116119
spin_unlock_irqrestore(&kprobe_lock, flags);
120+
arch_remove_kprobe(p);
117121
}
118122

119123
static struct notifier_block kprobe_exceptions_nb = {

0 commit comments

Comments
 (0)