[RFC,2/7] core/device: NULL pointer dereference fix

Message ID 20180921080511.22026-3-npiggin@gmail.com
State New
Headers show
Series
  • virtual memory patches
Related show

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied

Commit Message

Nicholas Piggin Sept. 21, 2018, 8:05 a.m.
This was caught with unmapped memory dereference page faults.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 core/device.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch

diff --git a/core/device.c b/core/device.c
index 19a8d8d6..6364a60e 100644
--- a/core/device.c
+++ b/core/device.c
@@ -494,7 +494,10 @@  struct dt_property *dt_add_property_string(struct dt_node *node,
 					   const char *name,
 					   const char *value)
 {
-	return dt_add_property(node, name, value, strlen(value)+1);
+	size_t len = 0;
+	if (value)
+		len = strlen(value) + 1;
+	return dt_add_property(node, name, value, len);
 }
 
 struct dt_property *dt_add_property_nstr(struct dt_node *node,