[Skiboot] [PATCH 2/6] hdata/vpd: Don't dereference possible NULL model_name

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


It's legitimate to just add model-name to the device tree if we have
one, which is what the hdata logic tries to do, but subtley fails
in one of the code paths.

Found by static analysis

Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
 hdata/vpd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hdata/vpd.c b/hdata/vpd.c
index a2c8906ca501..9a0e0da9b186 100644
--- a/hdata/vpd.c
+++ b/hdata/vpd.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.
@@ -527,12 +527,12 @@ static void dt_add_model_name(void)
 def_model:
 	if (!model_name || model_name[0] == '\0') {
 		mi = machine_info_lookup(model->prop);
-		if (mi) {
+		if (mi)
 			model_name = mi->name;
-		}
 	}
 
-	dt_add_property_string(dt_root, "model-name", model_name);
+	if(model_name)
+		dt_add_property_string(dt_root, "model-name", model_name);
 }
 
 static void sysvpd_parse_opp(const void *sysvpd, unsigned int sysvpd_sz)
-- 
2.9.4



More information about the Skiboot mailing list