[MM] [PATCH] iface-modem: Fix crash in expire_signal_quality due to removed skeleton.



expire_signal_quality() may be called after the DBus object skeleton is
removed in mm_iface_modem_shutdown() and before
signal_quality_update_context_free() is called due to the destruction of
the modem object. This patch prevents expire_signal_quality() from
accessing an already removed skeleton.
---
 src/mm-iface-modem.c |   36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c
index 49a18a5..86e7489 100644
--- a/src/mm-iface-modem.c
+++ b/src/mm-iface-modem.c
@@ -717,24 +717,26 @@ expire_signal_quality (MMIfaceModem *self)
                   MM_IFACE_MODEM_DBUS_SKELETON, &skeleton,
                   NULL);
 
-    old = mm_gdbus_modem_get_signal_quality (skeleton);
-    g_variant_get (old,
-                   "(ub)",
-                   &signal_quality,
-                   &recent);
-
-    /* If value is already not recent, we're done */
-    if (recent) {
-        mm_dbg ("Signal quality value not updated in %us, "
-                "marking as not being recent",
-                SIGNAL_QUALITY_RECENT_TIMEOUT_SEC);
-        mm_gdbus_modem_set_signal_quality (skeleton,
-                                           g_variant_new ("(ub)",
-                                                          signal_quality,
-                                                          FALSE));
-    }
+    if (skeleton) {
+        old = mm_gdbus_modem_get_signal_quality (skeleton);
+        g_variant_get (old,
+                       "(ub)",
+                       &signal_quality,
+                       &recent);
+
+        /* If value is already not recent, we're done */
+        if (recent) {
+            mm_dbg ("Signal quality value not updated in %us, "
+                    "marking as not being recent",
+                    SIGNAL_QUALITY_RECENT_TIMEOUT_SEC);
+            mm_gdbus_modem_set_signal_quality (skeleton,
+                                               g_variant_new ("(ub)",
+                                                              signal_quality,
+                                                              FALSE));
+        }
 
-    g_object_unref (skeleton);
+        g_object_unref (skeleton);
+    }
 
     /* Remove source id */
     ctx = g_object_get_qdata (G_OBJECT (self), signal_quality_update_context_quark);
-- 
1.7.7.3



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]