From: Marek Szyprowski Date: Wed, 2 Oct 2019 12:37:20 +0000 (+0200) Subject: linux_compat: fix potential NULL pointer access X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=2ad98ab8f68c71e2db140c6d5f1020aa6fbacb9e;p=u-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;