plugins/wifi: Fix GSupplicantInterface socket leak on out-of-band drop
PATCH 1/1 plugins/wifi: Fix GSupplicantInterface socket leak on out-of-band drop
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.
---
plugins/wifi.c +0 -0
@@ -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);
}