From 521f0ba4f891fd4a508a6d3e15f8504317336ca2 Mon Sep 17 00:00:00 2001 From: Dawid Niedzwiecki Date: Mon, 19 Jun 2023 09:02:43 +0000 Subject: [PATCH] mgmt: ec_host_cmd: clear response buffer every command The response buffer has to be cleared every command not to pass unintended content e.g. response from a previous command, or stack content. Signed-off-by: Dawid Niedzwiecki --- subsys/mgmt/ec_host_cmd/ec_host_cmd_handler.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subsys/mgmt/ec_host_cmd/ec_host_cmd_handler.c b/subsys/mgmt/ec_host_cmd/ec_host_cmd_handler.c index ff3b428ce589b6..784a6c9c0f8f1c 100644 --- a/subsys/mgmt/ec_host_cmd/ec_host_cmd_handler.c +++ b/subsys/mgmt/ec_host_cmd/ec_host_cmd_handler.c @@ -274,6 +274,12 @@ FUNC_NORETURN static void ec_host_cmd_thread(void *hc_handle, void *arg2, void * continue; } + /* + * Pre-emptively clear the entire response buffer so we do not + * have any left over contents from previous host commands. + */ + memset(args.output_buf, 0, args.output_buf_max); + status = found_handler->handler(&args); ec_host_cmd_send_response(status, &args);