Netdev List
 help / color / mirror / Atom feed
From: Lee Keon-Hyeong <leegun25@proton.me>
To: alex.aring@gmail.com, stefan@datenfreihafen.org,
	miquel.raynal@bootlin.com
Cc: linux-wpan@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH net v2 1/2] mac802154: free a replaced child
Date: Tue, 24 Nov 2026 08:59:12 +0000	[thread overview]
Message-ID: <20261124085905.710751-1-leegun25@proton.me> (raw)

When an associated child retransmits an ASSOC REQ, the coordinator
removes the old entry from the list but never frees it.  It also
increments wpan_dev->nchildren even though the number of children
has not changed.

Free the old entry and increment nchildren only when adding a new child.

With alloc_addr=0 the lookup in cfg802154_device_is_child() matches:
300 retransmissions from one peer leak 300 kmalloc-32 objects and make
the association table look full.

I found this during an LLM-assisted code review and reproduced it with
mac802154_hwsim.

After 501 retransmissions, the kmalloc-32 object count stayed at 840
with the series applied.  On the unpatched kernel it rose from 780 to
1260.  Kernel selftests were not run.

Fixes: 601f160b61b2 ("mac802154: Handle association requests from peers")
Signed-off-by: Lee Keon-Hyeong <leegun25@proton.me>
---
v2: Drop the added comment and move the lookup fix to patch 2/2.
v1: https://lore.kernel.org/r/20261121133101.240921-1-leegun25@proton.me

 net/mac802154/scan.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/mac802154/scan.c b/net/mac802154/scan.c
index d393b1f4e74e..943641702646 100644
--- a/net/mac802154/scan.c
+++ b/net/mac802154/scan.c
@@ -888,10 +888,12 @@ int mac802154_process_association_req(struct ieee802154_sub_if_data *sdata,
 		dev_dbg(&sdata->dev->dev,
 			"Child %8phC was already known\n", &ceaddr);
 		list_del(&exchild->node);
+		kfree(exchild);
+	} else {
+		wpan_dev->nchildren++;
 	}
 
 	list_add(&child->node, &wpan_dev->children);
-	wpan_dev->nchildren++;
 
 unlock:
 	mutex_unlock(&wpan_dev->association_lock);
-- 
2.56.0



             reply	other threads:[~2026-11-24  8:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  8:59 Lee Keon-Hyeong [this message]
2026-11-24  8:59 ` [PATCH net v2 2/2] mac802154: look up children by extended address Lee Keon-Hyeong
2026-11-25 13:45   ` Miquel Raynal
2026-11-25 13:47 ` [PATCH net v2 1/2] mac802154: free a replaced child Miquel Raynal

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=20261124085905.710751-1-leegun25@proton.me \
    --to=leegun25@proton.me \
    --cc=alex.aring@gmail.com \
    --cc=linux-wpan@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=stefan@datenfreihafen.org \
    /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