]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sandbox: cros_ec: Only write EC state when the EC is probed
authorSimon Glass <sjg@chromium.org>
Mon, 15 Mar 2021 05:11:08 +0000 (18:11 +1300)
committerSimon Glass <sjg@chromium.org>
Sat, 27 Mar 2021 02:04:31 +0000 (15:04 +1300)
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>
drivers/misc/cros_ec_sandbox.c

index cb8adc4495ab0432841e2e46c0d4971de4e5aab3..bc01df0904eb46b9f22878744ba4312d9b054541 100644 (file)
@@ -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);
 }