summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-09-26 10:40:36 +0200
committerAleksander Morgado <aleksander@aleksander.es>2017-09-26 10:50:34 +0200
commitee1e9afb8fbb67342a86b5c5f8f27a33797913a2 (patch)
tree28b8fb7d687027ef6b434b442987e512f42c33fa
parent544f9c3f7fc9d6617c47d53e4c873c68e6ea2051 (diff)
downloadModemManager-ee1e9afb8fbb67342a86b5c5f8f27a33797913a2.tar.gz
huawei: plug memleak when listing cdc-wdm AT ports
The returned list contains full references, so make sure we unref them before going on. Note that it's ok to return a pointer to one object inside this list even if we're unref-ing them all, because we're sure that the caller knows it's peek-ing a port object. (cherry picked from commit 4c36bd42d4fcbb13f7349bd50130dbc6bbf8597a)
-rw-r--r--plugins/huawei/mm-broadband-modem-huawei.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c
index 2d82908c1..9ce91ca66 100644
--- a/plugins/huawei/mm-broadband-modem-huawei.c
+++ b/plugins/huawei/mm-broadband-modem-huawei.c
@@ -2308,6 +2308,7 @@ peek_port_at_for_data (MMBroadbandModemHuawei *self,
{
GList *cdc_wdm_at_ports, *l;
const gchar *net_port_parent_path;
+ MMPortSerialAt *found = NULL;
g_warn_if_fail (mm_port_get_subsys (port) == MM_PORT_SUBSYS_NET);
net_port_parent_path = mm_port_get_parent_path (port);
@@ -2321,16 +2322,17 @@ peek_port_at_for_data (MMBroadbandModemHuawei *self,
MM_PORT_SUBSYS_USB,
MM_PORT_TYPE_AT,
NULL);
- for (l = cdc_wdm_at_ports; l; l = g_list_next (l)) {
+ for (l = cdc_wdm_at_ports; l && !found; l = g_list_next (l)) {
const gchar *wdm_port_parent_path;
g_assert (MM_IS_PORT_SERIAL_AT (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_SERIAL_AT (l->data);
+ found = MM_PORT_SERIAL_AT (l->data);
}
- return NULL;
+ g_list_free_full (cdc_wdm_at_ports, g_object_unref);
+ return found;
}