[PATCH] Kprobes: Oops! in unregister_kprobe()
authorPrasanna S Panchamukhi <prasanna@in.ibm.com>
Thu, 5 May 2005 23:15:41 +0000 (16:15 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 5 May 2005 23:36:39 +0000 (16:36 -0700)
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>
kernel/kprobes.c

index 1d5dd1337bd1cd4a089b13d1e67c749fe822234f..d8903e60c99abf3a73b57031cfdbaf86269ac9b3 100644 (file)
@@ -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 = {