diff mbox

buddy: Check zalloc() return value

Message ID 20170223032155.10589-1-stewart@linux.vnet.ibm.com
State Accepted
Headers show

Commit Message

Stewart Smith Feb. 23, 2017, 3:21 a.m. UTC
All callers of buddy_create() are correctly checking return value.

Found by static analysis

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

Comments

Stewart Smith March 3, 2017, 3:59 a.m. UTC | #1
Stewart Smith <stewart@linux.vnet.ibm.com> writes:
> All callers of buddy_create() are correctly checking return value.
>
> Found by static analysis
>
> Fixes: 8594b9c5bd456205255ea2241ba224f47480efad
> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>

Merged to master as of e812fd6053b92e8fae658b8731cc96c12f65270c
diff mbox

Patch

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