All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] firewire: core: fix potential memory leak in build_tree()
@ 2026-08-11 12:09 Takashi Sakamoto
  2026-08-11 12:09 ` [PATCH 1/3] firewire: core: consolidate port counting " Takashi Sakamoto
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Takashi Sakamoto @ 2026-08-11 12:09 UTC (permalink / raw)
  To: linux1394-devel; +Cc: nihaal, linux-kernel

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(-)


base-commit: f744022705b7eb479a1931ddd95aae4e9a4be221
-- 
2.53.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-08-13 11:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11 12:09 [PATCH 0/3] firewire: core: fix potential memory leak in build_tree() 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 ` [PATCH 0/3] firewire: core: fix potential memory leak in build_tree() Takashi Sakamoto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.