* [PATCH 3/3] lkdtm/heap: Check possible NULL pointer returned by vzalloc()
@ 2022-07-25 8:13 Ren Yu
2022-07-25 8:42 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Ren Yu @ 2022-07-25 8:13 UTC (permalink / raw)
To: keescook, arnd, gregkh, linux-kernel; +Cc: liqiong, yuzhe, Ren Yu
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 3/3] lkdtm/heap: Check possible NULL pointer returned by vzalloc()
2022-07-25 8:13 [PATCH 3/3] lkdtm/heap: Check possible NULL pointer returned by vzalloc() Ren Yu
@ 2022-07-25 8:42 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2022-07-25 8:42 UTC (permalink / raw)
To: Ren Yu; +Cc: keescook, arnd, linux-kernel, liqiong, yuzhe
On Mon, Jul 25, 2022 at 04:13:31PM +0800, Ren Yu wrote:
> As the possible alloc failure of the vzalloc(),the
> return pointer could be NULL.therefore it should be better to check it.
Odd punctuation and wrapping :(
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-25 8:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-25 8:13 [PATCH 3/3] lkdtm/heap: Check possible NULL pointer returned by vzalloc() Ren Yu
2022-07-25 8:42 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox