Skip to content
Snippets Groups Projects
Commit 5be60417 authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

Fix a crash triggered when firmware config takes too long

Fix a crash condition that is triggered when the firmware
configuration takes too long:
 1. The startup_timer expires, and it resets startup_future to NULL
 2. The delayed firmware_config_callback is received, and it
    tries to use the startup_future pointer (already set to NULL).

[Cherry-pick from AOSP]

Bug: 27336555
Change-Id: I4b04ca08a32c947f6f1eaabec7c4b099f96aab59
parent f6886e82
No related branches found
No related tags found
No related merge requests found
......@@ -416,17 +416,31 @@ static void event_finish_startup(UNUSED_ATTR void *context) {
static void firmware_config_callback(UNUSED_ATTR bool success) {
LOG_INFO(LOG_TAG, "%s", __func__);
firmware_is_configured = true;
alarm_cancel(startup_timer);
pthread_mutex_lock(&commands_pending_response_lock);
if (startup_future == NULL) {
// The firmware configuration took too long - ignore the callback
pthread_mutex_unlock(&commands_pending_response_lock);
return;
}
firmware_is_configured = true;
future_ready(startup_future, FUTURE_SUCCESS);
startup_future = NULL;
pthread_mutex_unlock(&commands_pending_response_lock);
}
static void startup_timer_expired(UNUSED_ATTR void *context) {
LOG_ERROR(LOG_TAG, "%s", __func__);
pthread_mutex_lock(&commands_pending_response_lock);
future_ready(startup_future, FUTURE_FAIL);
startup_future = NULL;
pthread_mutex_unlock(&commands_pending_response_lock);
}
// Postload functions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment