[Skiboot] [PATCH 1/6] hw/fsi-master: check zalloc return value

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


If we can't allocate enough memory for each chip struct mfsi, we're
not going to go so well during boot, so just assert that we allocated
the memory.

Found by static analysis

Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
 hw/fsi-master.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/fsi-master.c b/hw/fsi-master.c
index a13af44a8f4c..db433aa1a83a 100644
--- a/hw/fsi-master.c
+++ b/hw/fsi-master.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.
@@ -677,6 +677,7 @@ void mfsi_init(void)
 
 	for_each_chip(chip) {
 		chip->fsi_masters = zalloc(sizeof(struct mfsi) * 3);
+		assert(chip->fsi_masters);
 		mfsi_add(chip, &chip->fsi_masters[MFSI_cMFSI0], MFSI_cMFSI0);
 		mfsi_add(chip, &chip->fsi_masters[MFSI_hMFSI0], MFSI_hMFSI0);
 		mfsi_add(chip, &chip->fsi_masters[MFSI_cMFSI1], MFSI_cMFSI1);
-- 
2.9.4



More information about the Skiboot mailing list