From aab7366187e8feb3ffdb904767ffa550a44c9f2e Mon Sep 17 00:00:00 2001 From: Wei-Han Chen Date: Mon, 12 Mar 2018 20:11:23 +0800 Subject: [PATCH] usb_update: check touchpad_info size at build time Current protocol will not work if touchpad_info is more than 50 bytes. Assert this constrain at build time. BRANCH=none BUG=b:70482333 TEST=make BOARD=hammer Signed-off-by: Wei-Han Chen Change-Id: I9bf163f77f14c7d475fc8a2f422ce596dc89c61e Reviewed-on: https://chromium-review.googlesource.com/958893 Commit-Ready: Wei-Han Chen Tested-by: Wei-Han Chen Reviewed-by: Nicolas Boichat --- include/update_fw.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/update_fw.h b/include/update_fw.h index 727a3012f5..e454f129bd 100644 --- a/include/update_fw.h +++ b/include/update_fw.h @@ -8,6 +8,7 @@ #include +#include "compile_time_macros.h" /* * This file contains structures used to facilitate EC firmware updates @@ -217,6 +218,14 @@ struct touchpad_info { } elan; } __packed; +/* + * The response message must not exceed 64 bytes. + * And our protocol has a 14 bytes header. + * So the size of `struct touchpad_info` must be less + * than or equal to 50 bytes + */ +BUILD_ASSERT(sizeof(struct touchpad_info) <= 50); + void fw_update_command_handler(void *body, size_t cmd_size, size_t *response_size);