summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-10-31 18:16:08 -0700
committerGerrit <chrome-bot@google.com>2012-11-01 10:08:54 -0700
commite3c5f77924f1bb668e95f6c5bf7eb1ba2253d5ac (patch)
tree9ac39a427513046779b93664fca59cd5b4654b17
parent9a1548984d1bcfb6a2035110349af9e2e0f4531a (diff)
downloadchrome-ec-e3c5f77924f1bb668e95f6c5bf7eb1ba2253d5ac.tar.gz
link: Fix overflow in hibernate time calculation
The time out value passed to task_wait_event() is signed 32-bit and thus waiting for 24 hours will cause overflow. Limit max wait time. BUG=chrome-os-partner:15797 BRANCH=link TEST=Disconnect AC, shut down system, and close lid. From ec console, do 'hibdelay 8000' and then wait 2.5 hours. EC should have hibernated. (8000 is more than twice the max time for task_wait_event()) Change-Id: I5fa505554182e8bad6399c12a382ff71bb123d8f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/37095 Reviewed-by: Vic Yang <victoryang@chromium.org>
-rw-r--r--common/x86_power.c6
-rw-r--r--include/task.h3
2 files changed, 8 insertions, 1 deletions
diff --git a/common/x86_power.c b/common/x86_power.c
index 4d9f5bbcfe..1a31749cd2 100644
--- a/common/x86_power.c
+++ b/common/x86_power.c
@@ -446,8 +446,12 @@ void x86_power_task(void)
system_hibernate(0, 0);
}
else {
+ uint64_t wait = target_time - time_now;
+ if (wait > TASK_MAX_WAIT_US)
+ wait = TASK_MAX_WAIT_US;
+
/* Wait for a message */
- task_wait_event(target_time - time_now);
+ task_wait_event(wait);
}
}
diff --git a/include/task.h b/include/task.h
index 1a7fb1b86f..ff3fe30f60 100644
--- a/include/task.h
+++ b/include/task.h
@@ -26,6 +26,9 @@
*/
#define TASK_EVENT_TIMER (1U << 31)
+/* Maximum time for task_wait_event() */
+#define TASK_MAX_WAIT_US 0x7fffffff
+
/**
* Disable CPU interrupt bit.
*