[Skiboot] [PATCH] core/pel: Validate 'system-id' DT property before using

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Wed Aug 31 01:40:56 AEST 2016


Platforms like mambo doesn't populate 'system-id' DT property. Validate
these properties before using.

Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
 core/pel.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/core/pel.c b/core/pel.c
index 5df3e91..621699d 100644
--- a/core/pel.c
+++ b/core/pel.c
@@ -9,6 +9,8 @@
 static void create_mtms_section(struct errorlog *elog_data,
 					char *pel_buffer, int *pel_offset)
 {
+	const struct dt_property *p;
+
 	struct opal_mtms_section *mtms = (struct opal_mtms_section *)
 				(pel_buffer + *pel_offset);
 
@@ -20,10 +22,12 @@ static void create_mtms_section(struct errorlog *elog_data,
 
 	memset(mtms->model, 0x00, sizeof(mtms->model));
 	memcpy(mtms->model, dt_prop_get(dt_root, "model"), OPAL_SYS_MODEL_LEN);
+
 	memset(mtms->serial_no, 0x00, sizeof(mtms->serial_no));
+	p = dt_find_property(dt_root, "system-id");
+	if (p)
+		memcpy(mtms->serial_no, p->prop, OPAL_SYS_SERIAL_LEN);
 
-	memcpy(mtms->serial_no, dt_prop_get(dt_root, "system-id"),
-						 OPAL_SYS_SERIAL_LEN);
 	*pel_offset += MTMS_SECTION_SIZE;
 }
 
@@ -32,6 +36,7 @@ static void create_extended_header_section(struct errorlog *elog_data,
 					char *pel_buffer, int *pel_offset)
 {
 	const char  *opalmodel = NULL;
+	const struct dt_property *p;
 	uint64_t extd_time;
 
 	struct opal_extended_header_section *extdhdr =
@@ -49,8 +54,9 @@ static void create_extended_header_section(struct errorlog *elog_data,
 	memcpy(extdhdr->model, opalmodel, OPAL_SYS_MODEL_LEN);
 
 	memset(extdhdr->serial_no, 0x00, sizeof(extdhdr->serial_no));
-	memcpy(extdhdr->serial_no, dt_prop_get(dt_root, "system-id"),
-							OPAL_SYS_SERIAL_LEN);
+	p = dt_find_property(dt_root, "system-id");
+	if (p)
+		memcpy(extdhdr->serial_no, p->prop, OPAL_SYS_SERIAL_LEN);
 
 	memset(extdhdr->opal_release_version, 0x00,
 				sizeof(extdhdr->opal_release_version));



More information about the Skiboot mailing list