From: Sudip Mukherjee Date: Tue, 5 Apr 2016 17:11:06 +0000 (+0530) Subject: lkdtm: fix memory leak of base X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=d2e10088ce01191748857296999b8c24a9a51959;p=linux-beck.git 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 Signed-off-by: Kees Cook --- diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c index 2f0b02248761..5b3a63c87ec9 100644 --- a/drivers/misc/lkdtm.c +++ b/drivers/misc/lkdtm.c @@ -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;