[PATCH] plugins/wifi: Fix GSupplicantInterface socket leak on out-of-band drop

[email protected]
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
When an unmanaged or virtual interface changes state or drops, 
interface_removed() is invoked within the wireless event pathways. 

If wifi or wifi->device has already been cleared or unlinked during the 
topology shift, the function triggers an early return. This conditional
block accidentally bypasses the mandatory
g_supplicant_interface_cancel()
and data unreferencing routines. As a result, low-level netlink and
event 
file descriptors are permanently leaked in the process table.

Refactor interface_removed() to ensure that the core supplicant 
interface resource cancellation runs unconditionally before releasing
control.

Signed-off-by: Doemela <[email protected]>
---
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 9ce7b5a..bcf8321 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1014,14 +1014,16 @@ static void
interface_removed(GSupplicantInterface *interface)
 	wifi = g_supplicant_interface_get_data(interface);
 
 	if (wifi != NULL && wifi->tethering == TRUE)
 		return;
 
-	if (wifi == NULL || wifi->device == NULL) {
-		DBG("wifi interface already removed");
-		return;
-	}
+	if (wifi != NULL && wifi->device != NULL) {
+		wifi->interface = NULL;
+		connman_device_set_powered(wifi->device, FALSE);
+	} else {
+		DBG("wifi device linkage missing, executing isolated interface
cleanup");
+	}
 
-	wifi->interface = 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.