broadband-modem-{qmi,mbim}: port cleanups always during dispose()

If we need to disconnect signal handlers for the different port
objects managed in the QMI/MBIM modems, we need to do that during
dispose(), as there is no guarantee at all that the port objects will
exist in the MMBaseModem by the time finalize() is run.

  ModemManager[4183]: <debug> [1579097652.255333] Modem (Sierra) '/sys/devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8.4' completely disposed
  ModemManager[4183]: [/dev/cdc-wdm1] unexpected port hangup!
  ModemManager[4183]: [/dev/cdc-wdm1] channel destroyed
  ModemManager[4183]: <info>  [1579097652.258186] Connection to mbim-proxy for /dev/cdc-wdm1 lost, reprobing

  (ModemManager:4183): GLib-GObject-WARNING **: 15:14:12.258: invalid unclassed pointer in cast to 'MMBaseModem'
  ModemManager[4183]: mm_base_modem_set_reprobe: assertion 'MM_IS_BASE_MODEM (self)' failed

  (ModemManager:4183): GLib-GObject-WARNING **: 15:14:12.258: invalid unclassed pointer in cast to 'MMBaseModem'
  ModemManager[4183]: mm_base_modem_set_valid: assertion 'MM_IS_BASE_MODEM (self)' failed
  ModemManager[4183]: [/dev/cdc-wdm1] unexpected port hangup!
  ModemManager[4183]: [/dev/cdc-wdm1] channel destroyed
  ModemManager[4183]: [/dev/cdc-wdm1] MBIM error: Cannot write message: Broken pipe
  ModemManager[4183]: [/dev/cdc-wdm1] MBIM error: Cannot write message: Broken pipe
  ModemManager[4183]: [/dev/cdc-wdm1] MBIM error: Cannot write message: Broken pipe
  ModemManager[4183]: [/dev/cdc-wdm1] MBIM error: Cannot write message: Broken pipe
This commit is contained in:
Aleksander Morgado
2020-01-15 15:37:06 +01:00
parent 246fe710b7
commit 00bb228472
2 changed files with 26 additions and 1 deletions

View File

@@ -5319,11 +5319,14 @@ mm_broadband_modem_mbim_init (MMBroadbandModemMbim *self)
}
static void
finalize (GObject *object)
dispose (GObject *object)
{
MMBroadbandModemMbim *self = MM_BROADBAND_MODEM_MBIM (object);
MMPortMbim *mbim;
/* If any port cleanup is needed, it must be done during dispose(), as
* the modem object will be affected by an explciit g_object_run_dispose()
* that will remove all port references right away */
mbim = mm_base_modem_peek_port_mbim (MM_BASE_MODEM (self));
if (mbim) {
/* Explicitly remove notification handler */
@@ -5336,6 +5339,14 @@ finalize (GObject *object)
mm_port_mbim_close (mbim, NULL, NULL);
}
G_OBJECT_CLASS (mm_broadband_modem_mbim_parent_class)->dispose (object);
}
static void
finalize (GObject *object)
{
MMBroadbandModemMbim *self = MM_BROADBAND_MODEM_MBIM (object);
g_free (self->priv->caps_device_id);
g_free (self->priv->caps_firmware_info);
g_free (self->priv->caps_hardware_info);
@@ -5600,6 +5611,7 @@ mm_broadband_modem_mbim_class_init (MMBroadbandModemMbimClass *klass)
g_type_class_add_private (object_class, sizeof (MMBroadbandModemMbimPrivate));
object_class->dispose = dispose;
object_class->finalize = finalize;
broadband_modem_class->initialization_started = initialization_started;

View File

@@ -8650,6 +8650,19 @@ static void
dispose (GObject *object)
{
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (object);
MMPortQmi *qmi;
/* If any port cleanup is needed, it must be done during dispose(), as
* the modem object will be affected by an explciit g_object_run_dispose()
* that will remove all port references right away */
qmi = mm_base_modem_peek_port_qmi (MM_BASE_MODEM (self));
if (qmi) {
/* Disconnect signal handler for qmi-proxy disappearing, if it exists */
untrack_qmi_device_removed (self, qmi);
/* If we did open the QMI port during initialization, close it now */
if (mm_port_qmi_is_open (qmi))
mm_port_qmi_close (qmi);
}
g_list_free_full (self->priv->firmware_list, g_object_unref);
self->priv->firmware_list = NULL;