summaryrefslogtreecommitdiff
path: root/drivers/misc
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-15 08:11:08 +0300
committerSimon Glass <sjg@chromium.org>2021-03-27 05:04:31 +0300
commita5bc9abcee0ac8982c14f9cd585570a268eb9e47 (patch)
tree47b5ff1bb2c176d09c9ad1f50407b20d83eb7e6f /drivers/misc
parent5d8c37910d87828e914262991de7d5599d63692a (diff)
downloadu-boot-a5bc9abcee0ac8982c14f9cd585570a268eb9e47.tar.xz
sandbox: cros_ec: Only write EC state when the EC is probed
This can crash if the EC has not yet been probed. Add a check to prevent this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/cros_ec_sandbox.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c
index cb8adc4495..bc01df0904 100644
--- a/drivers/misc/cros_ec_sandbox.c
+++ b/drivers/misc/cros_ec_sandbox.c
@@ -153,10 +153,14 @@ static int cros_ec_write_state(void *blob, int node)
{
struct ec_state *ec = g_state;
+ if (!g_state)
+ return 0;
+
/* We are guaranteed enough space to write basic properties */
fdt_setprop_u32(blob, node, "current-image", ec->current_image);
fdt_setprop(blob, node, "vbnv-context", ec->vbnv_context,
sizeof(ec->vbnv_context));
+
return state_setprop(node, "flash-data", ec->flash_data,
ec->ec_config.flash.length);
}