[PATCH v2] plugins/wifi: Fix GSupplicantInterface socket leak during teardown

[email protected]
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
When a virtual or unmanaged wifi interface is dropped out-of-band, 
interface_removed() is invoked within the wireless event loop.

If the underlying wifi struct or its device linkage has already been 
cleared during a topology shift, the current logic bypasses the 
mandatory g_supplicant_interface_cancel() and data unreferencing 
routines due to missing fallback handling. This causes netlink and 
event file descriptors to permanently leak in the process table.

Refactor interface_removed() to ensure resource cancellation runs 
unconditionally, even if device pointers are already gone.

Signed-off-by: Doemela <[email protected]>
---
diff --git a/plugins/wifi.c b/plugins/wifi.c
index d18dc6cd..df938c1a 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -2284,14 +2284,14 @@ static void
interface_removed(GSupplicantInterface *interface)
 
 	wifi = g_supplicant_interface_get_data(interface);
 
 	if (wifi)
 		wifi->interface = NULL;
 
 	if (wifi && wifi->tethering)
 		return;
 
-	if (wifi == NULL || wifi->device == NULL)
-		return;
-
-	connman_device_set_powered(wifi->device, FALSE);
+	if (wifi != NULL && wifi->device != NULL)
+		connman_device_set_powered(wifi->device, FALSE);
+
+	g_supplicant_interface_set_data(interface, NULL);
+	g_supplicant_interface_cancel(interface);
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.