[PATCH 1/2] wispr: Ensure memory cleaned up in all cases

Ed Rose | Tewke <[email protected]> Thu, 12 Mar 2026 15:14:57 +0000
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
If `connman_proxy_lookup` fails to resolve a proxy, the code path fails=0A=
to unref the `connman_wispr_portal_context` resulting in a resource=0A=
leak of both memory and file descriptors. This can lead to connman=0A=
hitting it's OS fd limit and becoming non-functional.=0A=
=0A=
Resolve this by ensuring the reference count for the portal context is=0A=
always decremented, even in error cases.=0A=
---=0A=
 src/wispr.c | 3 ++-=0A=
 1 file changed, 2 insertions(+), 1 deletion(-)=0A=
=0A=
diff --git a/src/wispr.c b/src/wispr.c=0A=
index a40cf353..a8e16b7e 100644=0A=
--- a/src/wispr.c=0A=
+++ b/src/wispr.c=0A=
@@ -1303,7 +1303,7 @@ static void proxy_callback(const char *proxy, void *u=
ser_data)=0A=
=0A=
 		portal_manage_failure_status(wp_context, 0, "no valid proxy");=0A=
=0A=
-		return;=0A=
+		goto done;=0A=
 	}=0A=
=0A=
 	DBG("proxy %s", proxy);=0A=
@@ -1328,6 +1328,7 @@ static void proxy_callback(const char *proxy, void *u=
ser_data)=0A=
 					xml_wispr_parser_callback, wp_context);=0A=
=0A=
 	wispr_portal_request_portal(wp_context);=0A=
+done:=0A=
 	wispr_portal_context_unref(wp_context);=0A=
 }=0A=
=0A=
--=0A=
2.43.0=0A=
=0A=