[Skiboot] [PATCH] mambo: Add NULL checks and error messages

Cyril Bur cyril.bur at au1.ibm.com
Mon Jul 11 11:35:09 AEST 2016


While it extremely unlikely that these paths will ever by triggered
the error message could be useful to help diagnose a broken system.

This patch also fixes coverity issue 127700

Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
 platforms/mambo/mambo.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/platforms/mambo/mambo.c b/platforms/mambo/mambo.c
index 154c734..69e0796 100644
--- a/platforms/mambo/mambo.c
+++ b/platforms/mambo/mambo.c
@@ -197,6 +197,12 @@ static void bogus_disk_flash_init(void)
 
 		bl = zalloc(sizeof(struct blocklevel_device));
 		bdi = zalloc(sizeof(struct bogus_disk_info));
+		if (!bl || !bdi) {
+			free(bl);
+			free(bdi);
+			prerror("mambo: Failed to start bogus disk, ENOMEM\n");
+			return;
+		}
 
 		bl->read = &bogus_disk_read;
 		bl->write = &bogus_disk_write;
-- 
2.9.0



More information about the Skiboot mailing list