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 <m.szyprowski@samsung.com>
Reviewed-by: Ralph Siemsen <ralph.siemsen@linaro.org>
This commit is contained in:
Marek Szyprowski 2019-10-02 14:37:20 +02:00 committed by Tom Rini
parent 9b3fbb2b43
commit 2ad98ab8f6

View file

@ -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;