From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: linux1394-devel@lists.sourceforge.net
Cc: nihaal@cse.iitm.ac.in, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/3] firewire: core: fix potential memory leak in build_tree()
Date: Thu, 13 Aug 2026 20:39:40 +0900 [thread overview]
Message-ID: <20260813113940.GA738240@sakamocchi.jp> (raw)
In-Reply-To: <20260811120928.700577-1-o-takashi@sakamocchi.jp>
On Tue, Aug 11, 2026 at 09:09:25PM +0900, Takashi Sakamoto wrote:
> Hi,
>
> This patchset fixes a potential memory leak in the error path of
> build_tree(), reported by Abdun Nihaal[1].
>
> The first two patches refactor build tree() to optimize port counting and
> the place of parent port validation. The last patch fixes the error path
> to release allocated node instances properly.
>
> The changes were verified using the kmem:kmalloc and kmem:kfree
> tracepoints together with the KUnit tests added in my former patchset[2].
> The kmem:kfree events appear in the issued cases:
>
> ```
> kmalloc: call_site=build_tree+0x228/0x620 ptr=ffffa10b013f0b00 bytes_req=64 bytes_alloc=64 gfp_flags=GFP_ATOMIC|__GFP_ZERO node=-1 accounted=false
> kmalloc: call_site=build_tree+0x228/0x620 ptr=ffffa10b013f0b40 bytes_req=48 bytes_alloc=64 gfp_flags=GFP_ATOMIC|__GFP_ZERO node=-1 accounted=false
> kmalloc: call_site=build_tree+0x228/0x620 ptr=ffffa10b013f0b80 bytes_req=64 bytes_alloc=64 gfp_flags=GFP_ATOMIC|__GFP_ZERO node=-1 accounted=false
> firewire_core node_tree_test_invalid_parent_port_count.dummy-device: parent port inconsistency for node 3: parent_count=2
> kfree: call_site=for_each_fw_node+0x17c/0x230 ptr=ffffa10b013f0b80
> kfree: call_site=for_each_fw_node+0x17c/0x230 ptr=ffffa10b013f0b00
> kfree: call_site=for_each_fw_node+0x17c/0x230 ptr=ffffa10b013f0b40
> ```
>
> [1][PATCH v2] firewire: core: fix possible memory leak in build_tree()
> https://lore.kernel.org/lkml/20260801110915.82561-1-nihaal@cse.iitm.ac.in/
> [2][PATCH 0/3] firewire: core: add KUnit tests for tree building
> https://lore.kernel.org/lkml/20260810064119.410324-1-o-takashi@sakamocchi.jp/
>
>
> Takashi Sakamoto (3):
> firewire: core: consolidate port counting in build_tree()
> firewire: core: validate parent port count before allocating nodes in
> build_tree()
> firewire: core: fix memory leak in error path of build_tree()
>
> drivers/firewire/core-topology.c | 58 ++++++++++++++++++++------------
> 1 file changed, 36 insertions(+), 22 deletions(-)
Applied to for-next branch, with some removals of code comments in
node-tree-test.c addressing to the memory leak.
Regards
Takashi Sakamoto
prev parent reply other threads:[~2026-08-13 11:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 12:09 Takashi Sakamoto
2026-08-11 12:09 ` [PATCH 1/3] firewire: core: consolidate port counting " Takashi Sakamoto
2026-08-11 12:09 ` [PATCH 2/3] firewire: core: validate parent port count before allocating nodes " Takashi Sakamoto
2026-08-11 12:09 ` [PATCH 3/3] firewire: core: fix memory leak in error path of build_tree() Takashi Sakamoto
2026-08-12 9:05 ` Abdun Nihaal
2026-08-12 10:21 ` Takashi Sakamoto
2026-08-13 11:39 ` Takashi Sakamoto [this message]
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=20260813113940.GA738240@sakamocchi.jp \
--to=o-takashi@sakamocchi.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
--cc=nihaal@cse.iitm.ac.in \
/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®