aboutsummaryrefslogtreecommitdiff
path: root/src/mm-broadband-modem.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-05-23 00:38:09 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-05-24 12:52:52 +0000
commit3da3623e11f90e45951118119da6f842053fd133 (patch)
tree0aa70687ba9ee225208cb6677b33e983e4aa49de /src/mm-broadband-modem.c
parent1f10b3ff7f2e9cf8a72859fc7340bc60bb189c2e (diff)
broadband-modem: check if skeleton exists when creating device id
The logic that creates the device identifier uses some fields that are exposed in DBus (e.g. model, manufacturer...). We should not attempt to load any of that info if the DBus skeleton for the Modem interface is no longer available, as e.g. the device may have gone away already. Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/374
Diffstat (limited to 'src/mm-broadband-modem.c')
-rw-r--r--src/mm-broadband-modem.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index 6e679aef..ee2adfc8 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -1146,9 +1146,9 @@ modem_load_device_identifier_finish (MMIfaceModem *self,
GAsyncResult *res,
GError **error)
{
- GError *inner_error = NULL;
- gpointer ctx = NULL;
- gchar *device_identifier;
+ GError *inner_error = NULL;
+ gpointer ctx = NULL;
+ gchar *device_identifier;
mm_base_modem_at_sequence_finish (MM_BASE_MODEM (self), res, &ctx, &inner_error);
if (inner_error) {
@@ -1157,10 +1157,16 @@ modem_load_device_identifier_finish (MMIfaceModem *self,
}
g_assert (ctx != NULL);
- device_identifier = (mm_broadband_modem_create_device_identifier (
- MM_BROADBAND_MODEM (self),
- ((DeviceIdentifierContext *)ctx)->ati,
- ((DeviceIdentifierContext *)ctx)->ati1));
+ device_identifier = mm_broadband_modem_create_device_identifier (
+ MM_BROADBAND_MODEM (self),
+ ((DeviceIdentifierContext *)ctx)->ati,
+ ((DeviceIdentifierContext *)ctx)->ati1,
+ &inner_error);
+ if (!device_identifier) {
+ g_propagate_error (error, inner_error);
+ return NULL;
+ }
+
mm_obj_dbg (self, "loaded device identifier: %s", device_identifier);
return device_identifier;
}
@@ -12521,10 +12527,18 @@ mm_broadband_modem_get_current_charset (MMBroadbandModem *self)
/*****************************************************************************/
gchar *
-mm_broadband_modem_create_device_identifier (MMBroadbandModem *self,
- const gchar *ati,
- const gchar *ati1)
-{
+mm_broadband_modem_create_device_identifier (MMBroadbandModem *self,
+ const gchar *ati,
+ const gchar *ati1,
+ GError **error)
+{
+ /* do nothing if device has gone already */
+ if (!self->priv->modem_dbus_skeleton) {
+ g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
+ "Modem interface skeleton unavailable");
+ return NULL;
+ }
+
return (mm_create_device_identifier (
mm_base_modem_get_vendor_id (MM_BASE_MODEM (self)),
mm_base_modem_get_product_id (MM_BASE_MODEM (self)),