broadband-modem-mbim: fix task completion when peeking device fails
We cannot call peek_device() when we have already created a GTask for the async operation, because if the operation failed we would be completing the async operation with a totally different GTask than the one we had created ourselves, triggering memory leaks and leaving modem references around that should not exist (as the GTask we create holds a modem reference). Issue found in the context of debugging this, may actually be fully related: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/550
This commit is contained in:
@@ -194,6 +194,25 @@ peek_device (gpointer self,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
peek_device_in_task (gpointer self,
|
||||||
|
MbimDevice **o_device,
|
||||||
|
GTask *task)
|
||||||
|
|
||||||
|
{
|
||||||
|
MMPortMbim *port;
|
||||||
|
|
||||||
|
port = mm_broadband_modem_mbim_peek_port_mbim (MM_BROADBAND_MODEM_MBIM (self));
|
||||||
|
if (!port) {
|
||||||
|
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Couldn't peek MBIM port");
|
||||||
|
g_object_unref (task);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*o_device = mm_port_mbim_peek_device (port);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
||||||
|
|
||||||
static QmiClient *
|
static QmiClient *
|
||||||
@@ -8603,7 +8622,7 @@ load_sim_slots_mbim (GTask *task)
|
|||||||
|
|
||||||
self = g_task_get_source_object (task);
|
self = g_task_get_source_object (task);
|
||||||
|
|
||||||
if (!peek_device (self, &device, NULL, NULL))
|
if (!peek_device_in_task (self, &device, task))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
message = mbim_message_ms_basic_connect_extensions_sys_caps_query_new (NULL);
|
message = mbim_message_ms_basic_connect_extensions_sys_caps_query_new (NULL);
|
||||||
@@ -8792,7 +8811,7 @@ set_primary_sim_slot_mbim (GTask *task)
|
|||||||
|
|
||||||
self = g_task_get_source_object (task);
|
self = g_task_get_source_object (task);
|
||||||
|
|
||||||
if (!peek_device (self, &device, NULL, NULL))
|
if (!peek_device_in_task (self, &device, task))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
message = mbim_message_ms_basic_connect_extensions_device_slot_mappings_query_new (NULL);
|
message = mbim_message_ms_basic_connect_extensions_device_slot_mappings_query_new (NULL);
|
||||||
|
Reference in New Issue
Block a user