From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 1/4] tlv: fix memory leak
Date: Fri, 07 Nov 2025 13:00:51 +0100 [thread overview]
Message-ID: <20251107-memleaks-v1-1-c7b74a2ae9db@pengutronix.de> (raw)
In-Reply-To: <20251107-memleaks-v1-0-c7b74a2ae9db@pengutronix.de>
of_new_node(of_new_node(NULL, NULL), ...) leaks memory of the parent
node which is never freed. Fix this by allocating a reusable parent
node in tlv_bus_register().
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/tlv/bus.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/common/tlv/bus.c b/common/tlv/bus.c
index 4dbffd365667b258991e5ab01a99be4ee225fee2..a59f8d297a27975a43dd98230e04593150bf250d 100644
--- a/common/tlv/bus.c
+++ b/common/tlv/bus.c
@@ -14,6 +14,8 @@ static void tlv_devinfo(struct device *dev)
printf("Magic: %08x\n", tlvdev->magic);
}
+static struct device_node *tlv_parent_node;
+
struct tlv_device *tlv_register_device(struct tlv_header *header,
struct device *parent)
{
@@ -42,7 +44,7 @@ struct tlv_device *tlv_register_device(struct tlv_header *header,
if (!name)
dev_set_name(dev, "tlv%u", id++);
- dev->device_node = of_new_node(of_new_node(NULL, NULL), dev_name(dev));
+ dev->device_node = of_new_node(tlv_parent_node, dev_name(dev));
dev->device_node->dev = dev;
register_device(dev);
@@ -123,6 +125,8 @@ static int tlv_bus_register(void)
{
int ret;
+ tlv_parent_node = of_new_node(NULL, NULL);
+
ret = bus_register(&tlv_bus);
if (ret)
return ret;
--
2.47.3
next prev parent reply other threads:[~2025-11-07 12:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 12:00 [PATCH 0/4] fix some memory leaks Sascha Hauer
2025-11-07 12:00 ` Sascha Hauer [this message]
2025-11-07 12:00 ` [PATCH 2/4] of: free of_fixup in of_unregister_fixup() Sascha Hauer
2025-11-07 12:00 ` [PATCH 3/4] bobject: free object name in bobject_del() Sascha Hauer
2025-11-10 13:48 ` Sascha Hauer
2025-11-07 12:00 ` [PATCH 4/4] bfetch: fix memory leak Sascha Hauer
2025-11-10 13:46 ` [PATCH 0/4] fix some memory leaks Sascha Hauer
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=20251107-memleaks-v1-1-c7b74a2ae9db@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.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