[Skiboot] [PATCH 6/6] core/mem_region: check return value of add_region

Stewart Smith stewart at linux.vnet.ibm.com
Tue Jul 4 15:21:06 AEST 2017


The only sensible thing to do if this fails is to abort() as we've
likely just failed reserving reserved memory regions, and nothing
good comes from that.

Found by static analysis

Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
 core/mem_region.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/core/mem_region.c b/core/mem_region.c
index 8d1363f551cb..77324d715160 100644
--- a/core/mem_region.c
+++ b/core/mem_region.c
@@ -1,4 +1,4 @@
-/* Copyright 2013-2014 IBM Corp.
+/* Copyright 2013-2017 IBM Corp.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -947,7 +947,10 @@ static void mem_region_parse_reserved_properties(void)
 					dt_get_number(range, 2),
 					dt_get_number(range + 1, 2),
 					NULL, REGION_FW_RESERVED);
-			add_region(region);
+			if (!add_region(region)) {
+				prerror("Couldn't add mem_region %s\n", name);
+				abort();
+			}
 		}
 	} else if (names || ranges) {
 		prerror("Invalid properties: reserved-names=%p "
-- 
2.9.4



More information about the Skiboot mailing list