Skip to content

net: l2: ieee802154: ctx_lock taken but not given #78495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lorc-dev opened this issue Sep 16, 2024 · 1 comment · Fixed by #78532
Closed

net: l2: ieee802154: ctx_lock taken but not given #78495

lorc-dev opened this issue Sep 16, 2024 · 1 comment · Fixed by #78532
Labels
area: IEEE 802.15.4 bug The issue is a bug, or the PR is fixing a bug priority: high High impact/importance bug

Comments

@lorc-dev
Copy link
Contributor

Describe the bug
In ieeee802154_check_dst_addr() the ctx_lock is taken but not given when the PAN ID doesn't match.

Fix:

diff --git a/subsys/net/l2/ieee802154/ieee802154.c b/subsys/net/l2/ieee802154/ieee802154.c
--- a/subsys/net/l2/ieee802154/ieee802154.c	(revision 34982bb00b57486aeb83a6cb3bb7433791302aed)
+++ b/subsys/net/l2/ieee802154/ieee802154.c	(date 1726234192944)
@@ -317,7 +317,8 @@
 	if (!(dst_plain->pan_id == IEEE802154_BROADCAST_PAN_ID ||
 	      dst_plain->pan_id == sys_cpu_to_le16(ctx->pan_id))) {
 		LOG_DBG("Frame PAN ID does not match!");
-		return false;
+		ret = false;
+		goto out;
 	}
 
 	if (mhr->fs->fc.dst_addr_mode == IEEE802154_ADDR_MODE_SHORT) {

Similar issue in ieee802154_associate(), scan_ctx_lock is taken but not given when ieee802154_radio_send() fails.

diff --git a/subsys/net/l2/ieee802154/ieee802154_mgmt.c b/subsys/net/l2/ieee802154/ieee802154_mgmt.c
--- a/subsys/net/l2/ieee802154/ieee802154_mgmt.c	(revision 34982bb00b57486aeb83a6cb3bb7433791302aed)
+++ b/subsys/net/l2/ieee802154/ieee802154_mgmt.c	(date 1725975715608)
@@ -567,6 +567,7 @@
 	if (ieee802154_radio_send(iface, pkt, pkt->buffer)) {
 		net_pkt_unref(pkt);
 		ret = -EIO;
+		k_sem_give(&ctx->scan_ctx_lock);
 		NET_ERR("Could not associate: cannot send association request");
 		goto out;
 	}

Environment (please complete the following information):

  • OS: Windows
  • Zephyr SDK 0.16.8
  • 34982bb
@lorc-dev lorc-dev added the bug The issue is a bug, or the PR is fixing a bug label Sep 16, 2024
@zephyrbot zephyrbot assigned ghost Sep 16, 2024
@ghost ghost added the priority: high High impact/importance bug label Sep 17, 2024
@ghost
Copy link

ghost commented Sep 17, 2024

@lorc-dev Again, thanks for providing such a detailed bug report and analysis. Will fix.

nashif pushed a commit that referenced this issue Sep 25, 2024
When an incoming PAN ID does not match or when an error occurs while
sending association requests, then locks were not properly released.

Fixes #78495

Signed-off-by: Florian Grandel <[email protected]>
(cherry picked from commit 041d8c7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: IEEE 802.15.4 bug The issue is a bug, or the PR is fixing a bug priority: high High impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants