From: Marek Szyprowski Date: Wed, 2 Oct 2019 12:37:20 +0000 (+0200) Subject: linux_compat: fix potential NULL pointer access X-Git-Tag: v2020.01-rc2~28^2~7 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2ad98ab8f68c71e2db140c6d5f1020aa6fbacb9e;p=oweals%2Fu-boot.git 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 --- diff --git a/lib/linux_compat.c b/lib/linux_compat.c index 6373b4451e..81ea8fb126 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;