ConnMan network manager
 help / color / mirror / Atom feed
From: kasuta@riseup.net
To: connman@lists.linux.dev
Subject: [PATCH v2] plugins/wifi: Fix GSupplicantInterface socket leak during teardown
Date: Sun, 16 Aug 2026 18:17:51 +0000	[thread overview]
Message-ID: <98cff95babe8e6de463c9051751a9164@riseup.net> (raw)

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 <kasuta@riseup.net>
---
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);
 }

                 reply	other threads:[~2026-08-16 18:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=98cff95babe8e6de463c9051751a9164@riseup.net \
    --to=kasuta@riseup.net \
    --cc=connman@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox