[Skiboot] [PATCH] buddy: Check zalloc() return value

Stewart Smith stewart at linux.vnet.ibm.com
Thu Feb 23 14:21:55 AEDT 2017


All callers of buddy_create() are correctly checking return value.

Found by static analysis

Fixes: 8594b9c5bd456205255ea2241ba224f47480efad
Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
 core/buddy.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/core/buddy.c b/core/buddy.c
index 59cd2cb0fc86..b98a229d4950 100644
--- a/core/buddy.c
+++ b/core/buddy.c
@@ -286,6 +286,8 @@ struct buddy *buddy_create(unsigned int max_order)
 	bsize = BITMAP_BYTES(1u << (max_order + 1));
 
 	b = zalloc(sizeof(struct buddy) + bsize);
+	if (!b)
+		return NULL;
 	b->max_order = max_order;
 
 	BUDDY_NOISE("Map @%p, size: %d bytes\n", b->map, bsize);
-- 
2.9.3



More information about the Skiboot mailing list