Skip to content

Commit

Permalink
lkdtm: fix memory leak of val
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sudip Mukherjee authored and Kees Cook committed Apr 6, 2016
1 parent c4004b0 commit 50fbd97
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/misc/lkdtm.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,13 @@ static void lkdtm_do_action(enum ctype which)
}
case CT_READ_BUDDY_AFTER_FREE: {
unsigned long p = __get_free_page(GFP_KERNEL);
int saw, *val = kmalloc(1024, GFP_KERNEL);
int saw, *val;
int *base;

if (!p)
break;

val = kmalloc(1024, GFP_KERNEL);
if (!val)
break;

Expand Down

0 comments on commit 50fbd97

Please sign in to comment.