iface-modem-3gpp: fix crash when trying to set unknown power state
Certain QMI-based USB modems will report an "unknown" power state upon
boot, before our first attempt to set one:
$ sudo qmicli --dms-get-operating-mode -d /dev/cdc-wdm0 -p
[/dev/cdc-wdm0] Operating mode retrieved:
Mode: 'unknown'
HW restricted: 'no'
Due to this, the logic trying to recover the previous power state
during an attach settings update would end up asserting:
[modem3] set initial EPS bearer settings state (3/5): recover previous power state
**
ERROR:../src/mm-iface-modem.c:4554:mm_iface_modem_set_power_state:
code should not be reached
Bail out! ERROR:../src/mm-iface-modem.c:4554:mm_iface_modem_set_power_state:
code should not be reached
Aborted
This is a rare case, and instead of handling it in the QMI specific
implementation, we can try to fix it in a safer way directly in the
logic that handles the attach settings update. If we ever detect that
the reported power state is "unknown", we will default it to "on"
while emitting a warning.
This commit is contained in:
committed by
Aleksander Morgado
parent
891b1a41f9
commit
6c1888f76c
@@ -1329,6 +1329,13 @@ handle_set_initial_eps_bearer_settings_power_down_ready (MMIfaceModem
|
||||
mm_obj_warn (self, "failed to power down modem before updating initial EPS bearer settings: %s", ctx->saved_error->message);
|
||||
ctx->step = HANDLE_SET_INITIAL_EPS_BEARER_SETTINGS_STEP_LAST;
|
||||
} else {
|
||||
/* If we could not load the previous power state, assume it was 'on', which is the most likely
|
||||
* case on these type of failures. */
|
||||
if (ctx->previous_power_state == MM_MODEM_POWER_STATE_UNKNOWN) {
|
||||
mm_obj_warn (ctx->self, "power state before the initial EPS bearer settings is unknown, will assume 'on'");
|
||||
ctx->previous_power_state = MM_MODEM_POWER_STATE_ON;
|
||||
}
|
||||
|
||||
mm_obj_dbg (self, "modem power state updated: %s -> %s",
|
||||
mm_modem_power_state_get_string (ctx->previous_power_state),
|
||||
mm_modem_power_state_get_string (MM_MODEM_POWER_STATE_LOW));
|
||||
|
||||
Reference in New Issue
Block a user