[PATCH] Don't oops when unregistering unknown kprobes

From: Frederik Deweerdt
Date: Tue Apr 26 2005 - 11:27:52 EST


Hi Prasanna,

Here's a patch that handles gracefully attempts to unregister
unregistered kprobes (ie. a warning message instead of an oops).
Patch is against 2.6.12-rc3

Signed-off-by: Frederik Deweerdt <frederik.deweerdt@xxxxxxxxxxx>

Regards,
Frederik

--
o----------------------------------------------o
| http://open-news.net : l'info alternative |
| Tech - Sciences - Politique - International |
o----------------------------------------------o
--- linux-2.6.12-rc3/kernel/kprobes.c 2005-04-26 16:35:22.000000000 +0200
+++ linux-2.6.12-rc3-devel/kernel/kprobes.c 2005-04-26 16:44:57.000000000 +0200
@@ -107,6 +107,13 @@ rm_kprobe:
void unregister_kprobe(struct kprobe *p)
{
unsigned long flags;
+
+ if (!get_kprobe(p)) {
+ printk(KERN_WARNING "Warning: Attempt to unregister "
+ "unknown kprobe (addr:0x%lx)\n",
+ (unsigned long) p);
+ return;
+ }
arch_remove_kprobe(p);
spin_lock_irqsave(&kprobe_lock, flags);
*p->addr = p->opcode;