diff mbox series

[2/2] service: Both cancel and stop online checks where appropriate.

Message ID 20231215021653.2156275-3-gerickson@nuovations.com (mailing list archive)
State Not Applicable, archived
Headers show
Series service: Both Cancel and Stop Online Checks where Appropriate | expand

Commit Message

Grant Erickson Dec. 15, 2023, 2:16 a.m. UTC
This both cancels, via 'cancel_online_check', and stops, via
'__connman_wispr_stop' online checks on service disconnect or
free. The former terminates any in-flight or recurring check activity
in service.c and the latter terminates the same in wispr.c.

Failure to cancel as well as stop can lead to a use-after-free fault
in one-shot or continuous online check mode when a latent online check
reschedule timer fires after the service has been disconnected or
deallocated.
---
 src/service.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/src/service.c b/src/service.c
index 6f816ac7af01..020e43fa4038 100644
--- a/src/service.c
+++ b/src/service.c
@@ -6014,7 +6014,10 @@  static void service_free(gpointer user_data)
 	__connman_notifier_service_remove(service);
 	service_schedule_removed(service);
 
+	cancel_online_check(service, CONNMAN_IPCONFIG_TYPE_ALL);
+
 	__connman_wispr_stop(service);
+
 	stats_stop(service);
 
 	service->path = NULL;
@@ -7193,6 +7196,8 @@  static int service_indicate_state(struct connman_service *service)
 
 		default_changed();
 
+		cancel_online_check(service, CONNMAN_IPCONFIG_TYPE_ALL);
+
 		__connman_wispr_stop(service);
 
 		__connman_wpad_stop(service);