summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2017-11-27 15:43:41 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-11-28 15:44:13 -0800
commitc1654d300d2894198f4ca88a7d8426da49d191b5 (patch)
tree85bfe123a13c5b34997c95bb35010db728f70551
parent26b4617c4311860b15b6761734673c527cbc74ad (diff)
downloadchrome-ec-c1654d300d2894198f4ca88a7d8426da49d191b5.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: I062b82bdd30da28f62556ab4907a0f3bbf6d8126 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>
-rw-r--r--common/host_event_commands.c10
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