summaryrefslogtreecommitdiffstats
path: root/arch/csky/kernel/probes/kprobes.c
diff options
context:
space:
mode:
authorLiao Chang <liaochang1@huawei.com>2022-05-25 10:02:41 +0200
committerGuo Ren <guoren@linux.alibaba.com>2022-07-23 03:36:14 +0200
commita2310c74d418deca0f1d749c45f1f43162510f51 (patch)
tree69a0d22e32cfbcd7bcdde2917901f3fe526da8dd /arch/csky/kernel/probes/kprobes.c
parentLinux 5.19-rc7 (diff)
downloadlinux-a2310c74d418deca0f1d749c45f1f43162510f51.tar.xz
linux-a2310c74d418deca0f1d749c45f1f43162510f51.zip
csky/kprobe: reclaim insn_slot on kprobe unregistration
On kprobe registration kernel allocate one insn_slot for new kprobe, but it forget to reclaim the insn_slot on unregistration, leading to a potential leakage. Reported-by: Chen Guokai <chenguokai17@mails.ucas.ac.cn> Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Liao Chang <liaochang1@huawei.com> Signed-off-by: Guo Ren <guoren@kernel.org>
Diffstat (limited to 'arch/csky/kernel/probes/kprobes.c')
-rw-r--r--arch/csky/kernel/probes/kprobes.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/csky/kernel/probes/kprobes.c b/arch/csky/kernel/probes/kprobes.c
index 34ba684d5962..3c6e5c725d81 100644
--- a/arch/csky/kernel/probes/kprobes.c
+++ b/arch/csky/kernel/probes/kprobes.c
@@ -124,6 +124,10 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
void __kprobes arch_remove_kprobe(struct kprobe *p)
{
+ if (p->ainsn.api.insn) {
+ free_insn_slot(p->ainsn.api.insn, 0);
+ p->ainsn.api.insn = NULL;
+ }
}
static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb)