Skip to content

Commit

Permalink
lkdtm: fix memory leak of base
Browse files Browse the repository at this point in the history
This case is supposed to read from a memory after it has been freed,
but we missed freeing base if the memory 'val' could not be allocated.

Signed-off-by: Sudip Mukherjee <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
  • Loading branch information
sudipm-mukherjee authored and kees committed Apr 6, 2016
1 parent 50fbd97 commit d2e1008
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/misc/lkdtm.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,10 @@ static void lkdtm_do_action(enum ctype which)
break;

val = kmalloc(len, GFP_KERNEL);
if (!val)
if (!val) {
kfree(base);
break;
}

*val = 0x12345678;
base[offset] = *val;
Expand Down

0 comments on commit d2e1008

Please sign in to comment.