From 2ec985ec2406b7077f864185f05417196bd35645 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Mon, 26 Aug 2019 13:58:35 +0900 Subject: [PATCH] Fix handling logic of pending request 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 | 3 ++- bt-service-adaptation/services/adapter/bt-service-core-adapter.c | 3 ++- bt-service-adaptation/services/audio/bt-service-audio.c | 3 ++- bt-service-adaptation/services/device/bt-service-bonded-device.c | 3 ++- bt-service-adaptation/services/device/bt-service-core-device.c | 3 ++- bt-service-adaptation/services/gatt/bt-service-gatt.c | 3 ++- bt-service-adaptation/services/health/bt-service-hdp.c | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c b/bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c index a0c503a..f8cc07b 100644 --- a/bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c +++ b/bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c @@ -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; diff --git a/bt-service-adaptation/services/adapter/bt-service-core-adapter.c b/bt-service-adaptation/services/adapter/bt-service-core-adapter.c index fbec03a..b29eb15 100644 --- a/bt-service-adaptation/services/adapter/bt-service-core-adapter.c +++ b/bt-service-adaptation/services/adapter/bt-service-core-adapter.c @@ -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; diff --git a/bt-service-adaptation/services/audio/bt-service-audio.c b/bt-service-adaptation/services/audio/bt-service-audio.c index 17b2ade..09ff2ed 100644 --- a/bt-service-adaptation/services/audio/bt-service-audio.c +++ b/bt-service-adaptation/services/audio/bt-service-audio.c @@ -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; diff --git a/bt-service-adaptation/services/device/bt-service-bonded-device.c b/bt-service-adaptation/services/device/bt-service-bonded-device.c index 795ed52..f0830fd 100644 --- a/bt-service-adaptation/services/device/bt-service-bonded-device.c +++ b/bt-service-adaptation/services/device/bt-service-bonded-device.c @@ -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; diff --git a/bt-service-adaptation/services/device/bt-service-core-device.c b/bt-service-adaptation/services/device/bt-service-core-device.c index d896869..3ba947a 100644 --- a/bt-service-adaptation/services/device/bt-service-core-device.c +++ b/bt-service-adaptation/services/device/bt-service-core-device.c @@ -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; diff --git a/bt-service-adaptation/services/gatt/bt-service-gatt.c b/bt-service-adaptation/services/gatt/bt-service-gatt.c index c6a1315..8a9ffc2 100644 --- a/bt-service-adaptation/services/gatt/bt-service-gatt.c +++ b/bt-service-adaptation/services/gatt/bt-service-gatt.c @@ -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; diff --git a/bt-service-adaptation/services/health/bt-service-hdp.c b/bt-service-adaptation/services/health/bt-service-hdp.c index 1ef5cb2..76ed9e8 100644 --- a/bt-service-adaptation/services/health/bt-service-hdp.c +++ b/bt-service-adaptation/services/health/bt-service-hdp.c @@ -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; -- 2.7.4