Skip to content

Commit d2e1008

Browse files
sudipm-mukherjeekees
authored andcommitted
lkdtm: fix memory leak of base
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 <sudip.mukherjee@codethink.co.uk> Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent 50fbd97 commit d2e1008

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
@@ -458,8 +458,10 @@ static void lkdtm_do_action(enum ctype which)
458458
break;
459459

460460
val = kmalloc(len, GFP_KERNEL);
461-
if (!val)
461+
if (!val) {
462+
kfree(base);
462463
break;
464+
}
463465

464466
*val = 0x12345678;
465467
base[offset] = *val;

0 commit comments

Comments
 (0)