diff options
author | Furquan Shaikh <furquan@chromium.org> | 2017-11-27 15:43:41 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-04-16 09:20:32 +0000 |
commit | c7624254e5ce4da284df9daec696a9dc621cf019 (patch) | |
tree | fb7b8d23c67ac33070c06d20688f082ada168ec6 | |
parent | d0decbf1d041cda667c08506fe045b75e2f343b9 (diff) | |
download | chrome-ec-c7624254e5ce4da284df9daec696a9dc621cf019.tar.gz |
host_event_commands: Fix off-by-one error
This CL fixes two issues:
1. Host events are 1-based. So, if event0 is being requested to be set
in host_event_set_bit, nothing needs to be done.
2. To check if event needs to be set in upper 32-bit, check if the
event # is >32 and not >=32. (This issue was identified by coverity ID
179990).
BUG=b:69329196
BRANCH=None
TEST=make -j buildall
Change-Id: I18b42285bfe187e9f5a32a10a5e1475cdc43f816
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/791862
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
(cherry picked from commit c1654d300d2894198f4ca88a7d8426da49d191b5)
Reviewed-on: https://chromium-review.googlesource.com/989868
Reviewed-by: Joel Kitching <kitching@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Trybot-Ready: Joel Kitching <kitching@chromium.org>
-rw-r--r-- | common/host_event_commands.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/common/host_event_commands.c b/common/host_event_commands.c index 9da08c892c..0f092f6bea 100644 --- a/common/host_event_commands.c +++ b/common/host_event_commands.c @@ -29,8 +29,16 @@ static void host_event_set_bit(host_event_t *ev, uint8_t bit) uint32_t *ptr = (uint32_t *)ev; *ev = 0; + + /* + * Host events are 1-based, so return early if event 0 is requested to + * be set. + */ + if (bit == 0) + return; + #ifdef CONFIG_HOST_EVENT64 - if (bit >= 32) + if (bit > 32) *(ptr + 1) = HOST_EVENT_32BIT_MASK(bit - 32); else #endif |