From b5782e9bc60ba52380d52455d8a1548bbb08151b Mon Sep 17 00:00:00 2001 From: Deokhyun Kim Date: Thu, 30 Jul 2020 16:56:46 +0900 Subject: [PATCH] Fix mem leak Change-Id: If133d1f4816cfcf0aad49f887a940bbdd1d318aa Signed-off-by: Deokhyun Kim Signed-off-by: Wootak Jung --- bt-oal/bluez_hal/src/bt-hal-device-dbus-handler.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/bt-oal/bluez_hal/src/bt-hal-device-dbus-handler.c b/bt-oal/bluez_hal/src/bt-hal-device-dbus-handler.c index 32fb468..fdf462c 100644 --- a/bt-oal/bluez_hal/src/bt-hal-device-dbus-handler.c +++ b/bt-oal/bluez_hal/src/bt-hal-device-dbus-handler.c @@ -198,15 +198,14 @@ int _bt_hal_device_remove_bond(const bt_bdaddr_t *bd_addr) device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE, NULL, BT_HAL_BLUEZ_NAME, device_path, BT_HAL_PROPERTIES_INTERFACE, NULL, NULL); - if (device_proxy != NULL) { - ret = g_dbus_proxy_call_sync(device_proxy, "Get", g_variant_new("(ss)", BT_HAL_DEVICE_INTERFACE, "Paired"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); + g_object_unref(device_proxy); if (error) { ERR("Getting property failed: [%s]\n", error->message); g_error_free(error); @@ -214,7 +213,6 @@ int _bt_hal_device_remove_bond(const bt_bdaddr_t *bd_addr) } else { if (!ret) { ERR("No paired device"); - g_object_unref(device_proxy); return BT_STATUS_NOT_PAIRED; } @@ -224,7 +222,6 @@ int _bt_hal_device_remove_bond(const bt_bdaddr_t *bd_addr) g_variant_unref(value); g_variant_unref(ret); } - g_object_unref(device_proxy); } if (is_paired == FALSE) { @@ -372,7 +369,6 @@ int _bt_hal_dbus_get_remote_device_services(const bt_bdaddr_t *remote_addr) goto fail; } - g_dbus_proxy_call(device_proxy, "DiscoverServices", g_variant_new("(s)", ""), G_DBUS_CALL_FLAGS_NONE, @@ -531,7 +527,6 @@ static void __bt_hal_device_service_search_cb(GDBusProxy *proxy, GAsyncResult *r DBG("+"); g_dbus_proxy_call_finish(proxy, res, &err); - g_object_unref(proxy); /* Check event pointer */ @@ -732,6 +727,7 @@ static void __bt_hal_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res, g_dbus_proxy_call_finish(proxy, res, &err); device_path = g_dbus_proxy_get_object_path(proxy); _bt_hal_convert_device_path_to_address(device_path, dev_address); + g_object_unref(proxy); if (err != NULL) { g_dbus_error_strip_remote_error(err); @@ -1293,8 +1289,10 @@ int _bt_hal_device_get_service_connection_state( uuid = _bt_convert_service_id_to_uuid_string(rem_svc_id); DBG("uuid: %s", uuid); - if (!uuid) + if (!uuid) { + g_object_unref(device_proxy); return 0; + } result = g_dbus_proxy_call_sync(device_proxy, "IsConnectedProfile", g_variant_new("(s)", uuid), -- 2.7.4