Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 15012
b: refs/heads/master
c: b3e55c7
h: refs/heads/master
v: v3
  • Loading branch information
Mao, Bibo authored and Linus Torvalds committed Dec 12, 2005
1 parent 1a7e026 commit 382c8d5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3fe968f167975d10c639f03c4934f05a29da73c0
refs/heads/master: b3e55c727ff7349c5db722fbdb8d99a151e8e0bf
18 changes: 16 additions & 2 deletions trunk/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,16 @@ int __kprobes register_kprobe(struct kprobe *p)
int ret = 0;
unsigned long flags = 0;
struct kprobe *old_p;
struct module *mod;

if ((!kernel_text_address((unsigned long) p->addr)) ||
in_kprobes_functions((unsigned long) p->addr))
return -EINVAL;

if ((mod = module_text_address((unsigned long) p->addr)) &&
(unlikely(!try_module_get(mod))))
return -EINVAL;

if ((ret = in_kprobes_functions((unsigned long) p->addr)) != 0)
return ret;
if ((ret = arch_prepare_kprobe(p)) != 0)
goto rm_kprobe;

Expand All @@ -488,13 +495,16 @@ int __kprobes register_kprobe(struct kprobe *p)
rm_kprobe:
if (ret == -EEXIST)
arch_remove_kprobe(p);
if (ret && mod)
module_put(mod);
return ret;
}

void __kprobes unregister_kprobe(struct kprobe *p)
{
unsigned long flags;
struct kprobe *old_p;
struct module *mod;

spin_lock_irqsave(&kprobe_lock, flags);
old_p = get_kprobe(p->addr);
Expand All @@ -506,6 +516,10 @@ void __kprobes unregister_kprobe(struct kprobe *p)
cleanup_kprobe(p, flags);

synchronize_sched();

if ((mod = module_text_address((unsigned long)p->addr)))
module_put(mod);

if (old_p->pre_handler == aggr_pre_handler &&
list_empty(&old_p->list))
kfree(old_p);
Expand Down

0 comments on commit 382c8d5

Please sign in to comment.