aboutsummaryrefslogtreecommitdiff
path: root/src/mm-sms-qmi.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-10-11 09:23:49 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-10-11 09:23:49 +0200
commit014d0688ff2eebd5ef821ef74e20ba704b52634d (patch)
tree164821926361d2670968c5e4e8e5d8de4eac870c /src/mm-sms-qmi.c
parentba64c49f3689f6fbc4dd740a39941b691768b04a (diff)
core,qmi: don't assume QMI port is always available
When the modem gets unplugged all ports disappear from the modem, so don't assume the port is always given. E.g. if the unplug happens in the middle of the initialization sequence we may end up with nasty segfaults: Crash reason: SIGSEGV Crash address: 0x0 Thread 0 (crashed) 0 ModemManager!mm_qmi_port_peek_client [mm-qmi-port.c : 50 + 0x0] rbx = 0x00007fbb5c1d8010 r12 = 0x0000000000000003 r13 = 0x00007fbb5c1f9880 r14 = 0x00007fbb59a30980 r15 = 0x00007fbb5c187a60 rip = 0x00007fbb5a1a54c0 rsp = 0x00007fffc6c0f628 rbp = 0x00007fffc6c0f650 Found by: given as instruction pointer in context 1 ModemManager!peek_qmi_client [mm-broadband-modem-qmi.c : 109 + 0x24] rbx = 0x00007fbb5c1d8010 r12 = 0x0000000000000003 r13 = 0x00007fbb5c1f9880 r14 = 0x00007fbb59a30980 r15 = 0x00007fbb5c187a60 rip = 0x00007fbb5a193851 rsp = 0x00007fffc6c0f630 rbp = 0x00007fffc6c0f650 Found by: call frame info 2 ModemManager!ensure_qmi_client [mm-broadband-modem-qmi.c : 132 + 0x4] rbx = 0x00007fbb5c1d8010 r12 = 0x00007fbb5a165140 r13 = 0x00007fbb5c1f9880 r14 = 0x00007fbb59a30980 r15 = 0x00007fbb5c187a60 rip = 0x00007fbb5a1938e4 rsp = 0x00007fffc6c0f650 rbp = 0x00007fffc6c0f690 Found by: call frame info ... Reported by: Ben Chan <benchan@chromium.org>
Diffstat (limited to 'src/mm-sms-qmi.c')
-rw-r--r--src/mm-sms-qmi.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/mm-sms-qmi.c b/src/mm-sms-qmi.c
index 2b167ed2..fbdaeb02 100644
--- a/src/mm-sms-qmi.c
+++ b/src/mm-sms-qmi.c
@@ -43,16 +43,30 @@ ensure_qmi_client (MMSmsQmi *self,
{
MMBaseModem *modem = NULL;
QmiClient *client;
+ MMQmiPort *port;
g_object_get (self,
MM_SMS_MODEM, &modem,
NULL);
g_assert (MM_IS_BASE_MODEM (modem));
- client = mm_qmi_port_peek_client (mm_base_modem_peek_port_qmi (modem),
+ port = mm_base_modem_peek_port_qmi (modem);
+ g_object_unref (modem);
+
+ if (!port) {
+ g_simple_async_report_error_in_idle (G_OBJECT (self),
+ callback,
+ user_data,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't peek QMI port");
+ return FALSE;
+ }
+
+ client = mm_qmi_port_peek_client (port,
service,
MM_QMI_PORT_FLAG_DEFAULT);
- if (!client)
+ if (!client) {
g_simple_async_report_error_in_idle (G_OBJECT (self),
callback,
user_data,
@@ -60,11 +74,11 @@ ensure_qmi_client (MMSmsQmi *self,
MM_CORE_ERROR_FAILED,
"Couldn't peek client for service '%s'",
qmi_service_get_string (service));
- else
- *o_client = client;
+ return FALSE;
+ }
- g_object_unref (modem);
- return !!client;
+ *o_client = client;
+ return TRUE;
}
/*****************************************************************************/