From: Yige Jiang <yigejiang86@gmail.com>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: Yige Jiang <yigejiang86@gmail.com>,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] bcma: Put the OF node of a core when the core is released
Date: Wed, 25 Nov 2026 15:53:45 +0800 [thread overview]
Message-ID: <rc-b1-20261110-vc-179-09535b897585@gmail.com> (raw)
bcma_of_find_child_device() returns the matching child from inside
for_each_child_of_node(), so it hands a counted reference to its
caller. bcma_of_fill_device() stores that node in core->dev.of_node,
but bcma_release_core_dev() never puts it, so each core matched to a
DT node leaks one device_node reference when it is released.
The node normally comes from the base device tree, and base-DT nodes
are never freed: of_node_release() frees only detached OF_DYNAMIC
nodes, i.e. overlay or changeset nodes. On a normal DT system the leak
therefore has no memory effect.
Drop the reference in the release callback, where the lifetime of
the core ends. The node is still assigned before device_add() and is
not changed afterwards.
Fixes: 2101e533f41a ("bcma: register bcma as device tree driver")
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Based on linux-next next-20261109 (630059a5a632).
Compile-tested: arm64, aarch64-linux-gnu-gcc 14.2.0, W=1, COMPILE_TEST=y, BCMA=m, BCMA_HOST_PCI=y, BCMA_HOST_SOC=y, OF_DYNAMIC=y; drivers/bcma/{main,scan}.o built before and after, no new warnings.
No hardware or runtime test was performed.
An AI assistant traced the OF node reference and helped draft the fix.
The leak needs a DT-described bcma bus (a "brcm,bus-axi" SoC host such as BCM4708/BCM53xx, or a DT node under a bcma PCI host) and happens when a matched core is released (bus unbind, module unload).
drivers/bcma/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 72f045e6ed51..58d72580f09f 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -123,6 +123,7 @@ static void bcma_release_core_dev(struct device *dev)
iounmap(core->io_addr);
if (core->io_wrap)
iounmap(core->io_wrap);
+ of_node_put(dev->of_node);
kfree(core);
}
base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47
reply other threads:[~2026-11-25 7:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=rc-b1-20261110-vc-179-09535b897585@gmail.com \
--to=yigejiang86@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=zajec5@gmail.com \
/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
all inboxes | Powered by JetHome®