diff options
Diffstat (limited to 'src/mm-base-modem.c')
-rw-r--r-- | src/mm-base-modem.c | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c index 9cd7c5fab..243ccb954 100644 --- a/src/mm-base-modem.c +++ b/src/mm-base-modem.c @@ -534,6 +534,7 @@ mm_base_modem_peek_port_qmi_for_data (MMBaseModem *self, { GList *cdc_wdm_qmi_ports, *l; const gchar *net_port_parent_path; + MMPortQmi *found = NULL; g_warn_if_fail (mm_port_get_subsys (data) == MM_PORT_SUBSYS_NET); net_port_parent_path = mm_port_get_parent_path (data); @@ -551,21 +552,25 @@ mm_base_modem_peek_port_qmi_for_data (MMBaseModem *self, MM_PORT_SUBSYS_USB, MM_PORT_TYPE_QMI, NULL); - for (l = cdc_wdm_qmi_ports; l; l = g_list_next (l)) { + for (l = cdc_wdm_qmi_ports; l && !found; l = g_list_next (l)) { const gchar *wdm_port_parent_path; g_assert (MM_IS_PORT_QMI (l->data)); wdm_port_parent_path = mm_port_get_parent_path (MM_PORT (l->data)); if (wdm_port_parent_path && g_str_equal (wdm_port_parent_path, net_port_parent_path)) - return MM_PORT_QMI (l->data); + found = MM_PORT_QMI (l->data); } - g_set_error (error, - MM_CORE_ERROR, - MM_CORE_ERROR_NOT_FOUND, - "Couldn't find associated QMI port for 'net/%s'", - mm_port_get_device (data)); - return NULL; + g_list_free_full (cdc_wdm_qmi_ports, g_object_unref); + + if (!found) + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_NOT_FOUND, + "Couldn't find associated QMI port for 'net/%s'", + mm_port_get_device (data)); + + return found; } #endif /* WITH_QMI */ @@ -608,6 +613,7 @@ mm_base_modem_peek_port_mbim_for_data (MMBaseModem *self, { GList *cdc_wdm_mbim_ports, *l; const gchar *net_port_parent_path; + MMPortMbim *found = NULL; g_warn_if_fail (mm_port_get_subsys (data) == MM_PORT_SUBSYS_NET); net_port_parent_path = mm_port_get_parent_path (data); @@ -625,21 +631,26 @@ mm_base_modem_peek_port_mbim_for_data (MMBaseModem *self, MM_PORT_SUBSYS_USB, MM_PORT_TYPE_MBIM, NULL); - for (l = cdc_wdm_mbim_ports; l; l = g_list_next (l)) { + + for (l = cdc_wdm_mbim_ports; l && !found; l = g_list_next (l)) { const gchar *wdm_port_parent_path; g_assert (MM_IS_PORT_MBIM (l->data)); wdm_port_parent_path = mm_port_get_parent_path (MM_PORT (l->data)); if (wdm_port_parent_path && g_str_equal (wdm_port_parent_path, net_port_parent_path)) - return MM_PORT_MBIM (l->data); + found = MM_PORT_MBIM (l->data); } - g_set_error (error, - MM_CORE_ERROR, - MM_CORE_ERROR_NOT_FOUND, - "Couldn't find associated MBIM port for 'net/%s'", - mm_port_get_device (data)); - return NULL; + g_list_free_full (cdc_wdm_mbim_ports, g_object_unref); + + if (!found) + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_NOT_FOUND, + "Couldn't find associated MBIM port for 'net/%s'", + mm_port_get_device (data)); + + return found; } #endif /* WITH_MBIM */ |