Skip to content

Commit 8a683a4

Browse files
c1728p9adbridge
authored andcommitted
Fix sleep lock underflow in LowPowerTimer
If a LowPowerTimer is started and then goes out of scope then a deep sleep lock underflow can occur. This is because the the variable '_lock_deepsleep' is checked when starting the timer but is not checked in the destructor, which unconditionally releases the deep sleep lock.
1 parent 95b6acd commit 8a683a4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/Timer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ Timer::Timer(const ticker_data_t *data) : _running(), _start(), _time(), _ticker
3535
Timer::~Timer() {
3636
core_util_critical_section_enter();
3737
if (_running) {
38-
sleep_manager_unlock_deep_sleep();
38+
if(_lock_deepsleep) {
39+
sleep_manager_unlock_deep_sleep();
40+
}
3941
}
4042
_running = 0;
4143
core_util_critical_section_exit();

0 commit comments

Comments
 (0)