From: Prasanna S Panchamukhi Date: Thu, 5 May 2005 23:15:41 +0000 (-0700) Subject: [PATCH] Kprobes: Oops! in unregister_kprobe() X-Git-Tag: v2.6.12-rc4~75 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04dea5f93231204cc3ca0ab793ce76dbb10c86ba;p=linux-2.6 [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 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 1d5dd1337b..d8903e60c9 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -107,13 +107,17 @@ rm_kprobe: void unregister_kprobe(struct kprobe *p) { unsigned long flags; - arch_remove_kprobe(p); spin_lock_irqsave(&kprobe_lock, flags); + if (!get_kprobe(p->addr)) { + spin_unlock_irqrestore(&kprobe_lock, flags); + return; + } *p->addr = p->opcode; hlist_del(&p->hlist); flush_icache_range((unsigned long) p->addr, (unsigned long) p->addr + sizeof(kprobe_opcode_t)); spin_unlock_irqrestore(&kprobe_lock, flags); + arch_remove_kprobe(p); } static struct notifier_block kprobe_exceptions_nb = {