lkdtm: do not leak free page on kmalloc failure
authorKees Cook <keescook@chromium.org>
Wed, 6 Apr 2016 22:53:27 +0000 (15:53 -0700)
committerKees Cook <keescook@chromium.org>
Wed, 6 Apr 2016 23:22:25 +0000 (16:22 -0700)
This frees the allocated page if there is a kmalloc failure.

Signed-off-by: Kees Cook <keescook@chromium.org>
drivers/misc/lkdtm.c

index 5b3a63c..0a5cbbe 100644 (file)
@@ -507,8 +507,10 @@ static void lkdtm_do_action(enum ctype which)
                        break;
 
                val = kmalloc(1024, GFP_KERNEL);
-               if (!val)
+               if (!val) {
+                       free_page(p);
                        break;
+               }
 
                base = (int *)p;