From: Denis Kenzior <denkenz@gmail.com>
To: iwd@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH 4/6] netdev: Do not leak l_genl_msg on error
Date: Sun, 26 Nov 2023 20:53:01 -0600 [thread overview]
Message-ID: <20231127025320.1310543-4-denkenz@gmail.com> (raw)
In-Reply-To: <20231127025320.1310543-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 | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
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)
--
2.42.0
next prev parent reply other threads:[~2023-11-27 2:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-27 2:52 [PATCH 1/6] ie: Move AKM suite converter from netdev Denis Kenzior
2023-11-27 2:52 ` [PATCH 2/6] nl80211util: Move nl80211_append_rsn_attributes Denis Kenzior
2023-11-27 2:53 ` [PATCH 3/6] netdev: Don't duplicate vendor_ies Denis Kenzior
2023-11-27 2:53 ` Denis Kenzior [this message]
2023-11-27 4:41 ` [PATCH 4/6] netdev: Do not leak l_genl_msg on error Denis Kenzior
2023-11-27 2:53 ` [PATCH 5/6] netdev: Fix buffer overflow with 32 character ssids Denis Kenzior
2023-11-27 2:53 ` [PATCH 6/6] erp: Fix buffer overflow for 32 byte SSIDs Denis Kenzior
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=20231127025320.1310543-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