From a32a0e494b50c9b29e99368b9077844b1e0c1358 Mon Sep 17 00:00:00 2001 From: Carlo Lobrano Date: Tue, 20 Dec 2016 12:34:01 +0100 Subject: [PATCH] Fixed crash in SIM hot swap when removing the SIM mm_device_create_modem needs a valid object_manager instance to create the new modem, while the one provided before was cleared out by a call to mm_device_remove_modem few lines before. Since the newly created modem refers to the same HW device, we can use the same object_manager also. --- src/mm-device.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mm-device.c b/src/mm-device.c index 979c397..7e01cae 100644 --- a/src/mm-device.c +++ b/src/mm-device.c @@ -316,21 +316,25 @@ modem_valid (MMBaseModem *modem, MMDevice *self) { if (!mm_base_modem_get_valid (modem)) { + GDBusObjectManagerServer *object_manager = g_object_ref (self->priv->object_manager); + /* Modem no longer valid */ mm_device_remove_modem (self); if (mm_base_modem_get_reprobe (modem)) { GError *error = NULL; - if (!mm_device_create_modem (self, self->priv->object_manager, &error)) { - mm_warn ("Could not recreate modem for device '%s': %s", - self->priv->uid, - error ? error->message : "unknown"); + if (!mm_device_create_modem (self, object_manager, &error)) { + mm_warn ("Could not recreate modem for device '%s': %s", + self->priv->uid, + error ? error->message : "unknown"); g_error_free (error); } else { mm_dbg ("Modem recreated for device '%s'", self->priv->uid); } } + + g_object_unref (object_manager); } else { /* Modem now valid, export it, but only if we really have it around. * It may happen that the initialization sequence fails because the -- 2.7.4