Fix gatt attributes not freed issue 09/256509/1
authorWootak Jung <wootak.jung@samsung.com>
Tue, 6 Apr 2021 04:15:36 +0000 (13:15 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Tue, 6 Apr 2021 04:15:36 +0000 (13:15 +0900)
next pointer should be set before removing gslist

Change-Id: I5a0e13ba2f9d35746a368d6fa42659b40f0ee91a
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-oal/bluez_hal/src/bt-hal-gatt-server.c

index 776a4d6..0dbdce5 100644 (file)
@@ -3065,14 +3065,16 @@ static bt_status_t gatt_server_delete_service(int server_if, int service_handle)
                        serv_info->serv_path, service_handle);
        }
 
-       for (l = serv_info->char_data; l != NULL; l = g_slist_next(l)) {
+       for (l = serv_info->char_data; l != NULL;) {
                struct gatt_char_info *char_info = l->data;
+               l = g_slist_next(l);
 
                if (char_info == NULL)
                        break;
 
-               for (l1 = char_info->desc_data; l1 != NULL; l1 = g_slist_next(l1)) {
+               for (l1 = char_info->desc_data; l1 != NULL;) {
                        struct gatt_desc_info *desc_info = l1->data;
+                       l1 = g_slist_next(l1);
 
                        if (desc_info == NULL)
                                break;
@@ -3091,6 +3093,7 @@ static bt_status_t gatt_server_delete_service(int server_if, int service_handle)
                        /* list remove & free */
                        char_info->desc_data = g_slist_remove(char_info->desc_data, desc_info);
                        __bt_hal_free_gatt_handle(BT_GATT_TYPE_DESC, desc_info->desc_handle);
+                       INFO("desc handle(%d) removed successfully", desc_info->desc_handle);
                        __bt_hal_gatt_free_descriptor_info(desc_info);
                }
 
@@ -3110,6 +3113,7 @@ static bt_status_t gatt_server_delete_service(int server_if, int service_handle)
                /* list remove & free */
                serv_info->char_data = g_slist_remove(serv_info->char_data, char_info);
                __bt_hal_free_gatt_handle(BT_GATT_TYPE_CHAR, char_info->char_handle);
+               INFO("char handle(%d) removed successfully", char_info->char_handle);
                __bt_hal_gatt_free_characteristic_info(char_info);
        }
 
@@ -3132,7 +3136,8 @@ static bt_status_t gatt_server_delete_service(int server_if, int service_handle)
        /* Remove from global list */
        gatt_services = g_slist_remove(gatt_services, serv_info);
        __bt_hal_free_gatt_handle(BT_GATT_TYPE_SERV, serv_info->service_handle);
-       INFO("After removing from global list total service dount [%d]", g_slist_length(gatt_services));
+       INFO("serv handle(%d) removed successfully", serv_info->service_handle);
+       INFO("After removing from global list total service count [%d]", g_slist_length(gatt_services));
 
        /* Remove from GATT Server's list of services */
        _bt_remote_service_from_gatt_server(server_if, service_handle);