aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2024-10-16 13:08:00 +0200
committerAleksander Morgado <aleksander@aleksander.es>2024-10-21 09:14:00 +0000
commit6c1888f76cd4e675210508e666d4a1d0e686d466 (patch)
treef1d4cac7342a30bdc030958803b74397e73cee46 /src
parent891b1a41f997e231242673eb6e3fd8517529fb29 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/mm-iface-modem-3gpp.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c
index 6d029e86..94d51f86 100644
--- a/src/mm-iface-modem-3gpp.c
+++ b/src/mm-iface-modem-3gpp.c
@@ -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));