Skip to content

Commit 50fbd97

Browse files
sudipm-mukherjeekees
authored andcommitted
lkdtm: fix memory leak of val
This case is supposed to read from a page after after it is freed, but it missed freeing val if we are not able to get a free page. Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk> Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent c4004b0 commit 50fbd97

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/misc/lkdtm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,13 @@ static void lkdtm_do_action(enum ctype which)
498498
}
499499
case CT_READ_BUDDY_AFTER_FREE: {
500500
unsigned long p = __get_free_page(GFP_KERNEL);
501-
int saw, *val = kmalloc(1024, GFP_KERNEL);
501+
int saw, *val;
502502
int *base;
503503

504504
if (!p)
505505
break;
506506

507+
val = kmalloc(1024, GFP_KERNEL);
507508
if (!val)
508509
break;
509510

0 commit comments

Comments
 (0)