[U-Boot] [PATCH] linux_compat: fix potential NULL pointer access

Marek Szyprowski m.szyprowski at samsung.com
Wed Oct 2 12:37:20 UTC 2019


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 at samsung.com>
---
 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 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;
-- 
2.17.1



More information about the U-Boot mailing list