Skip to content

Commit 38115f2

Browse files
mhiramatIngo Molnar
authored andcommitted
kprobes/x86: Release insn_slot in failure path
The following commit: 003002e ("kprobes: Fix arch_prepare_kprobe to handle copy insn failures") returns an error if the copying of the instruction, but does not release the allocated insn_slot. Clean up correctly. Signed-off-by: Masami Hiramatsu <[email protected]> Cc: Ananth N Mavinakayanahalli <[email protected]> Cc: Anil S Keshavamurthy <[email protected]> Cc: David S . Miller <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Fixes: 003002e ("kprobes: Fix arch_prepare_kprobe to handle copy insn failures") Link: http://lkml.kernel.org/r/150064834183.6172.11694375818447664416.stgit@devbox Signed-off-by: Ingo Molnar <[email protected]>
1 parent ba883b4 commit 38115f2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

arch/x86/kernel/kprobes/core.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ static int arch_copy_kprobe(struct kprobe *p)
457457

458458
int arch_prepare_kprobe(struct kprobe *p)
459459
{
460+
int ret;
461+
460462
if (alternatives_text_reserved(p->addr, p->addr))
461463
return -EINVAL;
462464

@@ -467,7 +469,13 @@ int arch_prepare_kprobe(struct kprobe *p)
467469
if (!p->ainsn.insn)
468470
return -ENOMEM;
469471

470-
return arch_copy_kprobe(p);
472+
ret = arch_copy_kprobe(p);
473+
if (ret) {
474+
free_insn_slot(p->ainsn.insn, 0);
475+
p->ainsn.insn = NULL;
476+
}
477+
478+
return ret;
471479
}
472480

473481
void arch_arm_kprobe(struct kprobe *p)

0 commit comments

Comments
 (0)