From 2ad98ab8f68c71e2db140c6d5f1020aa6fbacb9e Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Wed, 2 Oct 2019 14:37:20 +0200 Subject: [PATCH] linux_compat: fix potential NULL pointer access malloc_cache_aligned() might return zero, so fix potential NULL pointer access if __GFP_ZERO flag is set. Signed-off-by: Marek Szyprowski Reviewed-by: Ralph Siemsen --- lib/linux_compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linux_compat.c b/lib/linux_compat.c index 6373b44..81ea8fb 100644 --- a/lib/linux_compat.c +++ b/lib/linux_compat.c @@ -20,7 +20,7 @@ void *kmalloc(size_t size, int flags) void *p; p = malloc_cache_aligned(size); - if (flags & __GFP_ZERO) + if (p && flags & __GFP_ZERO) memset(p, 0, size); return p; -- 2.7.4