diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2017-10-06 10:51:01 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2017-10-06 10:51:01 +0200 |
commit | efaa780de20d0631f978781109900739f36126f0 (patch) | |
tree | 662c22a05a2d0964a8705aa2e62f7e6826b66ea2 /src | |
parent | fd2bfb7e85f1924f70c50b7e0d21ef5fe3caef38 (diff) |
port-qmi: don't allow client allocation if port is closed
The internal QmiDevice will be gone when the port is closed, so we
cannot really do anything.
This avoid an issue happening when the modem goes away in the middle
of the client allocation logic performed by MMBroadbandModemQmi:
ModemManager[24820]: <debug> [1507279407.225777] Couldn't allocate client for service 'wms': Couldn't create client for service 'wms': CID allocation failed in the CTL client: Transaction timed out
ModemManager[24820]: qmi_device_allocate_client: assertion 'QMI_IS_DEVICE (self)' failed
==24820==
==24820== Process terminating with default action of signal 5 (SIGTRAP): dumping core
==24820== at 0x66E3411: ??? (in /usr/lib/libglib-2.0.so.0.5200.3)
==24820== by 0x66E46FA: g_logv (in /usr/lib/libglib-2.0.so.0.5200.3)
==24820== by 0x66E484E: g_log (in /usr/lib/libglib-2.0.so.0.5200.3)
==24820== by 0x538E259: qmi_device_allocate_client (qmi-device.c:1008)
==24820== by 0x1F5690: mm_port_qmi_allocate_client (mm-port-qmi.c:157)
==24820== by 0x1D20BA: allocate_next_client (mm-broadband-modem-qmi.c:11319)
==24820== by 0x1D2027: qmi_port_allocate_client_ready (mm-broadband-modem-qmi.c:11306)
==24820== by 0x612FD52: ??? (in /usr/lib/libgio-2.0.so.0.5200.3)
==24820== by 0x6130775: ??? (in /usr/lib/libgio-2.0.so.0.5200.3)
==24820== by 0x1F54E8: allocate_client_ready (mm-port-qmi.c:113)
==24820== by 0x612FD52: ??? (in /usr/lib/libgio-2.0.so.0.5200.3)
==24820== by 0x6130775: ??? (in /usr/lib/libgio-2.0.so.0.5200.3)
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-port-qmi.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/mm-port-qmi.c b/src/mm-port-qmi.c index 5810e095..e2f63054 100644 --- a/src/mm-port-qmi.c +++ b/src/mm-port-qmi.c @@ -132,15 +132,20 @@ mm_port_qmi_allocate_client (MMPortQmi *self, AllocateClientContext *ctx; GTask *task; + task = g_task_new (self, cancellable, callback, user_data); + + if (!mm_port_qmi_is_open (self)) { + g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_WRONG_STATE, + "Port is closed"); + g_object_unref (task); + return; + } + if (!!mm_port_qmi_peek_client (self, service, flag)) { - g_task_report_new_error (self, - callback, - user_data, - mm_port_qmi_allocate_client, - MM_CORE_ERROR, - MM_CORE_ERROR_EXISTS, + g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_EXISTS, "Client for service '%s' already allocated", qmi_service_get_string (service)); + g_object_unref (task); return; } @@ -148,11 +153,7 @@ mm_port_qmi_allocate_client (MMPortQmi *self, ctx->info = g_new0 (ServiceInfo, 1); ctx->info->service = service; ctx->info->flag = flag; - - task = g_task_new (self, cancellable, callback, user_data); - g_task_set_task_data (task, - ctx, - (GDestroyNotify)allocate_client_context_free); + g_task_set_task_data (task, ctx, (GDestroyNotify)allocate_client_context_free); qmi_device_allocate_client (self->priv->qmi_device, service, |