lkml.org 
[lkml]   [2022]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/3] lkdtm/heap: Check possible NULL pointer returned by vzalloc()
Date
As the possible alloc failure of the vzalloc(),the
return pointer could be NULL.therefore it should be better to check it.

Signed-off-by: Ren Yu <renyu@nfschina.com>
---
drivers/misc/lkdtm/heap.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/misc/lkdtm/heap.c b/drivers/misc/lkdtm/heap.c
index 62516078a619..399cdbbfd5b7 100644
--- a/drivers/misc/lkdtm/heap.c
+++ b/drivers/misc/lkdtm/heap.c
@@ -33,9 +33,13 @@ static void lkdtm_VMALLOC_LINEAR_OVERFLOW(void)
one = vzalloc(PAGE_SIZE);
two = vzalloc(PAGE_SIZE);

+ if (!one || !two)
+ goto free_kernel;
+
pr_info("Attempting vmalloc linear overflow ...\n");
memset(one, 0xAA, PAGE_SIZE + __offset);

+free_kernel:
vfree(two);
vfree(one);
}
--
2.11.0
\
 
 \ /
  Last update: 2022-07-25 10:15    [W:0.055 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site