]> Git Repo - J-u-boot.git/commitdiff
linux_compat: fix potential NULL pointer access
authorMarek Szyprowski <[email protected]>
Wed, 2 Oct 2019 12:37:20 +0000 (14:37 +0200)
committerTom Rini <[email protected]>
Thu, 31 Oct 2019 11:22:53 +0000 (07:22 -0400)
malloc_cache_aligned() might return zero, so fix potential NULL pointer
access if __GFP_ZERO flag is set.

Signed-off-by: Marek Szyprowski <[email protected]>
Reviewed-by: Ralph Siemsen <[email protected]>
lib/linux_compat.c

index 6373b4451eb3fdafaed99cfeb7eb40f7821712b0..81ea8fb126fa2fec7230479ae77d744cde337e4c 100644 (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;
This page took 0.029321 seconds and 4 git commands to generate.