Fix handling logic of pending request 74/212674/1
authorWootak Jung <wootak.jung@samsung.com>
Mon, 26 Aug 2019 04:58:35 +0000 (13:58 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Mon, 26 Aug 2019 04:58:35 +0000 (13:58 +0900)
If the list is removed during 'for' statement, 'list->next' also set NULL.
 Fix the logic to store 'list->next' in advance.

Change-Id: Iae4bb280f68d770b0528bbc5b9bbd38fb88f4884

bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c
bt-service-adaptation/services/adapter/bt-service-core-adapter.c
bt-service-adaptation/services/audio/bt-service-audio.c
bt-service-adaptation/services/device/bt-service-bonded-device.c
bt-service-adaptation/services/device/bt-service-core-device.c
bt-service-adaptation/services/gatt/bt-service-gatt.c
bt-service-adaptation/services/health/bt-service-hdp.c

index a0c503a..f8cc07b 100644 (file)
@@ -123,8 +123,9 @@ static void __bt_le_handle_pending_requests(int service_function, void *user_dat
        BT_INFO("+");
 
        /* Get method invocation context */
-       for (l = _bt_get_invocation_list(); l != NULL; l = g_slist_next(l)) {
+       for (l = _bt_get_invocation_list(); l != NULL; ) {
                req_info = l->data;
+               l = g_slist_next(l);
                if (req_info == NULL || req_info->service_function != service_function)
                        continue;
 
index fbec03a..b29eb15 100644 (file)
@@ -1094,8 +1094,9 @@ static void __bt_adapter_handle_pending_requests(int service_function, void *use
        BT_INFO("+");
 
        /* Get method invocation context */
-       for (l = _bt_get_invocation_list(); l != NULL; l = g_slist_next(l)) {
+       for (l = _bt_get_invocation_list(); l != NULL; ) {
                req_info = l->data;
+               l = g_slist_next(l);
                if (req_info == NULL || req_info->service_function != service_function)
                        continue;
 
index 17b2ade..09ff2ed 100644 (file)
@@ -1106,8 +1106,9 @@ static void __handle_pending_requests(int result, int service_function, void *us
        BT_DBG("+");
 
        /* Get method invocation context */
-       for (l = _bt_get_invocation_list(); l != NULL; l = g_slist_next(l)) {
+       for (l = _bt_get_invocation_list(); l != NULL; ) {
                req_info = l->data;
+               l = g_slist_next(l);
 
                if (req_info == NULL || req_info->service_function != service_function)
                        continue;
index 795ed52..f0830fd 100644 (file)
@@ -98,8 +98,9 @@ static void __bt_handle_pending_request(int result, int service_function)
        BT_DBG("+");
 
        /* Get method invocation context */
-       for (l = _bt_get_invocation_list(); l != NULL; l = g_slist_next(l)) {
+       for (l = _bt_get_invocation_list(); l != NULL; ) {
                req_info = l->data;
+               l = g_slist_next(l);
                if (req_info == NULL || req_info->service_function != service_function)
                        continue;
 
index d896869..3ba947a 100644 (file)
@@ -207,8 +207,9 @@ void __bt_device_handle_pending_requests(int result, int service_function,
        BT_DBG("+");
 
        /* Get method invocation context */
-       for (l = _bt_get_invocation_list(); l != NULL; l = g_slist_next(l)) {
+       for (l = _bt_get_invocation_list(); l != NULL; ) {
                req_info = l->data;
+               l = g_slist_next(l);
                if (req_info == NULL || req_info->service_function != service_function)
                        continue;
 
index c6a1315..8a9ffc2 100644 (file)
@@ -842,8 +842,9 @@ static void __bt_gatt_handle_pending_request_info(int result,
        ret_if(data == NULL);
        BT_DBG("+");
 
-       for (l = _bt_get_invocation_list(); l != NULL; l = g_slist_next(l)) {
+       for (l = _bt_get_invocation_list(); l != NULL; ) {
                req_info = l->data;
+               l = g_slist_next(l);
                if (req_info == NULL || req_info->service_function != service_function)
                        continue;
 
index 1ef5cb2..76ed9e8 100644 (file)
@@ -74,8 +74,9 @@ static void __bt_hdp_handle_pending_request_info(int result,
 
        BT_DBG("+");
 
-       for (l = _bt_get_invocation_list(); l != NULL; l = g_slist_next(l)) {
+       for (l = _bt_get_invocation_list(); l != NULL; ) {
                req_info = l->data;
+               l = g_slist_next(l);
                if (req_info == NULL || req_info->service_function != service_function)
                        continue;