[PATCH 03/19] sandbox: cros_ec: Only write EC state when the EC is probed

Heinrich Schuchardt xypron.glpk at gmx.de
Mon Mar 15 11:58:15 CET 2021


On 3/15/21 6:11 AM, Simon Glass wrote:
> This can crash if the EC has not yet been probed. Add a check to prevent

What does 'This' relate to? There seems a sentence to missing from the
commit message.

Best regards

Heinrich

> this.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
>   drivers/misc/cros_ec_sandbox.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c
> index cb8adc4495a..bc01df0904e 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);
>   }
>



More information about the U-Boot mailing list