Skip to content

Commit 3d085c7

Browse files
committed
lkdtm: do not leak free page on kmalloc failure
This frees the allocated page if there is a kmalloc failure. Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent d2e1008 commit 3d085c7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/misc/lkdtm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,10 @@ static void lkdtm_do_action(enum ctype which)
507507
break;
508508

509509
val = kmalloc(1024, GFP_KERNEL);
510-
if (!val)
510+
if (!val) {
511+
free_page(p);
511512
break;
513+
}
512514

513515
base = (int *)p;
514516

0 commit comments

Comments
 (0)