public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: iwd@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH v2 4/6] netdev: Do not leak l_genl_msg on error
Date: Sun, 26 Nov 2023 22:38:44 -0600	[thread overview]
Message-ID: <20231127043924.1328538-4-denkenz@gmail.com> (raw)
In-Reply-To: <20231127043924.1328538-1-denkenz@gmail.com>

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 | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/netdev.c b/src/netdev.c
index e7b502b1c3ba..901a41900350 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -2561,23 +2561,23 @@ 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,
-						netdev->connect_cmd,
+	netdev->connect_cmd_id = l_genl_family_send(nl80211, connect_cmd,
 						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)
-- 
2.42.0


  parent reply	other threads:[~2023-11-27  4:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-27  4:38 [PATCH v2 1/6] ie: Move AKM suite converter from netdev Denis Kenzior
2023-11-27  4:38 ` [PATCH v2 2/6] nl80211util: Move nl80211_append_rsn_attributes Denis Kenzior
2023-11-27  4:38 ` [PATCH v2 3/6] netdev: Don't duplicate vendor_ies Denis Kenzior
2023-11-27  4:38 ` Denis Kenzior [this message]
2023-11-27  4:38 ` [PATCH v2 5/6] netdev: Fix buffer overflow with 32 character ssids Denis Kenzior
2023-11-27  4:38 ` [PATCH v2 6/6] erp: Fix buffer overflow for 32 byte SSIDs Denis Kenzior
2023-11-27 10:30 ` [PATCH v2 1/6] ie: Move AKM suite converter from netdev Marcel Holtmann

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=20231127043924.1328538-4-denkenz@gmail.com \
    --to=denkenz@gmail.com \
    --cc=iwd@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