diff mbox series

[4/6] netdev: Do not leak l_genl_msg on error

Message ID 20231127025320.1310543-4-denkenz@gmail.com (mailing list archive)
State New
Headers show
Series [1/6] ie: Move AKM suite converter from netdev | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

Denis Kenzior Nov. 27, 2023, 2:53 a.m. UTC
In netdev_retry_owe, if l_gen_family_send fails, the connect_cmd is
never freed or reset.  Fix that.

While here, use a stack variable instead of netdev member, since the use
of such a member is unnecessary and confusing.
---
 src/netdev.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Denis Kenzior Nov. 27, 2023, 4:41 a.m. UTC | #1
>   	netdev->connect_cmd_id = l_genl_family_send(nl80211,

The send needs to also use connect_cmd, not netdev->connect_cmd.  Fixed in v2.
diff mbox series

Patch

diff --git a/src/netdev.c b/src/netdev.c
index e7b502b1c3ba..03f9a77324db 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -2561,10 +2561,12 @@  static void netdev_cmd_connect_cb(struct l_genl_msg *msg, void *user_data)
 
 static bool netdev_retry_owe(struct netdev *netdev)
 {
+	struct l_genl_msg *connect_cmd;
+
 	if (!owe_next_group(netdev->owe_sm))
 		return false;
 
-	netdev->connect_cmd = netdev_build_cmd_connect(netdev,
+	connect_cmd = netdev_build_cmd_connect(netdev,
 					netdev->handshake, NULL, NULL, 0);
 
 	netdev->connect_cmd_id = l_genl_family_send(nl80211,
@@ -2572,12 +2574,11 @@  static bool netdev_retry_owe(struct netdev *netdev)
 						netdev_cmd_connect_cb, netdev,
 						NULL);
 
-	if (!netdev->connect_cmd_id)
-		return false;
-
-	netdev->connect_cmd = NULL;
+	if (netdev->connect_cmd_id > 0)
+		return true;
 
-	return true;
+	l_genl_msg_unref(connect_cmd);
+	return false;
 }
 
 static void netdev_connect_event(struct l_genl_msg *msg, struct netdev *netdev)