aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2022-10-04 10:41:40 +0000
committerAleksander Morgado <aleksander@aleksander.es>2022-10-05 11:04:20 +0000
commiteee9a6f6b45966f774f937f6f3f1a5f92f219e22 (patch)
tree22b533df67750f39f43c08f06ed55cfea091fb86
parent976a3d4d826e5d9c6b66287c3d11c95318d45810 (diff)
iface-modem-3gpp: disallow Scan() or Register() if Locked
We are exporting the 3GPP interface even when locked, so we should cleanly disallow the Scan() and Register() operations on that state, instead of wrongly assuming they may never happen. 0x00007c192134944a (libc.so.6 + 0x0003744a) gsignal 0x00007c19213344e8 (libc.so.6 + 0x000224e8) abort 0x00007c19215c4221 (libglib-2.0.so.0 - gtestutils.c: 3253) g_assertion_message 0x00007c19215c4284 (libglib-2.0.so.0 - gtestutils.c: 3279) g_assertion_message_expr 0x00005b3eec9c9fbc (ModemManager - mm-iface-modem-3gpp.c) handle_scan_auth_ready 0x00007c19216ef75b (libgio-2.0.so.0 - gtask.c: 1230) g_task_return_now 0x00007c19216ee7b9 (libgio-2.0.so.0 - gtask.c: 1300) g_task_return 0x00005b3eec99a5ef (ModemManager - mm-dispatcher-fcc-unlock.c: 69) dispatcher_run_ready 0x00007c19216ef75b (libgio-2.0.so.0 - gtask.c: 1230) g_task_return_now 0x00007c19216ef78e (libgio-2.0.so.0 - gtask.c: 1244) complete_in_idle_cb 0x00007c19215a2486 (libglib-2.0.so.0 - gmain.c: 3417) g_main_context_dispatch 0x00007c19215a2791 (libglib-2.0.so.0 - gmain.c: 4211) g_main_context_iterate 0x00007c19215a2a05 (libglib-2.0.so.0 - gmain.c: 4411) g_main_loop_run 0x00005b3eec998451 (ModemManager - main.c: 217) main 0x00007c19213347a7 (libc.so.6 + 0x000227a7) __libc_start_main 0x00005b3eec998259 (ModemManager + 0x00060259) _start Fixes 83e7600a67d1c5952d0fada07ebe70dfef3492f6
-rw-r--r--src/mm-iface-modem-3gpp.c89
1 files changed, 17 insertions, 72 deletions
diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c
index 5c05178e..c7904f67 100644
--- a/src/mm-iface-modem-3gpp.c
+++ b/src/mm-iface-modem-3gpp.c
@@ -761,18 +761,18 @@ handle_register_auth_ready (MMBaseModem *self,
switch (modem_state) {
case MM_MODEM_STATE_FAILED:
case MM_MODEM_STATE_UNKNOWN:
- case MM_MODEM_STATE_LOCKED:
- /* We should never have such request (interface wasn't exported yet) */
- g_assert_not_reached ();
- break;
-
case MM_MODEM_STATE_INITIALIZING:
+ case MM_MODEM_STATE_LOCKED:
+ case MM_MODEM_STATE_DISABLED:
+ case MM_MODEM_STATE_DISABLING:
+ case MM_MODEM_STATE_ENABLING:
g_dbus_method_invocation_return_error (ctx->invocation,
MM_CORE_ERROR,
MM_CORE_ERROR_WRONG_STATE,
"Cannot register modem: "
- "device not fully initialized yet");
- break;
+ "not yet enabled");
+ handle_register_context_free (ctx);
+ return;
case MM_MODEM_STATE_ENABLED:
case MM_MODEM_STATE_SEARCHING:
@@ -785,23 +785,6 @@ handle_register_auth_ready (MMBaseModem *self,
ctx);
return;
- case MM_MODEM_STATE_DISABLING:
- g_dbus_method_invocation_return_error (ctx->invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_WRONG_STATE,
- "Cannot register modem: "
- "currently being disabled");
- break;
-
- case MM_MODEM_STATE_ENABLING:
- case MM_MODEM_STATE_DISABLED:
- g_dbus_method_invocation_return_error (ctx->invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_WRONG_STATE,
- "Cannot register modem: "
- "not yet enabled");
- break;
-
case MM_MODEM_STATE_DISCONNECTING:
case MM_MODEM_STATE_CONNECTING:
case MM_MODEM_STATE_CONNECTED:
@@ -810,13 +793,12 @@ handle_register_auth_ready (MMBaseModem *self,
MM_CORE_ERROR_WRONG_STATE,
"Cannot register modem: "
"modem is connected");
- break;
+ handle_register_context_free (ctx);
+ return;
default:
g_assert_not_reached ();
}
-
- handle_register_context_free (ctx);
}
static gboolean
@@ -925,7 +907,6 @@ handle_scan_auth_ready (MMBaseModem *self,
GAsyncResult *res,
HandleScanContext *ctx)
{
- MMModemState modem_state;
GError *error = NULL;
if (!mm_base_modem_authorize_finish (self, res, &error)) {
@@ -945,53 +926,17 @@ handle_scan_auth_ready (MMBaseModem *self,
return;
}
- modem_state = MM_MODEM_STATE_UNKNOWN;
- g_object_get (self,
- MM_IFACE_MODEM_STATE, &modem_state,
- NULL);
-
- switch (modem_state) {
- case MM_MODEM_STATE_FAILED:
- case MM_MODEM_STATE_UNKNOWN:
- case MM_MODEM_STATE_LOCKED:
- /* We should never have such request (interface wasn't exported yet) */
- g_assert_not_reached ();
- break;
-
- case MM_MODEM_STATE_INITIALIZING:
- g_dbus_method_invocation_return_error (ctx->invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_WRONG_STATE,
- "Cannot scan networks: "
- "device not fully initialized yet");
- break;
-
- case MM_MODEM_STATE_DISABLED:
- case MM_MODEM_STATE_DISABLING:
- case MM_MODEM_STATE_ENABLING:
- g_dbus_method_invocation_return_error (ctx->invocation,
- MM_CORE_ERROR,
- MM_CORE_ERROR_WRONG_STATE,
- "Cannot scan networks: not enabled yet");
- break;
-
- case MM_MODEM_STATE_ENABLED:
- case MM_MODEM_STATE_SEARCHING:
- case MM_MODEM_STATE_REGISTERED:
- case MM_MODEM_STATE_DISCONNECTING:
- case MM_MODEM_STATE_CONNECTING:
- case MM_MODEM_STATE_CONNECTED:
- MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->scan_networks (
- MM_IFACE_MODEM_3GPP (self),
- (GAsyncReadyCallback)handle_scan_ready,
- ctx);
+ if (mm_iface_modem_abort_invocation_if_state_not_reached (MM_IFACE_MODEM (self),
+ ctx->invocation,
+ MM_MODEM_STATE_ENABLED)) {
+ handle_scan_context_free (ctx);
return;
-
- default:
- g_assert_not_reached ();
}
- handle_scan_context_free (ctx);
+ MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->scan_networks (
+ MM_IFACE_MODEM_3GPP (self),
+ (GAsyncReadyCallback)handle_scan_ready,
+ ctx);
}
static gboolean