[PATCH] firewire: core: fix possible memory leak in build_tree()

From: Abdun Nihaal

Date: Mon Jul 27 2026 - 06:12:20 EST


The memory allocated for node in fw_node_create() is not freed when a
parent port inconsistency error occurs. Fix that by adding a kfree().

Fixes: 3038e353cfaf ("firewire: Add core firewire stack.")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Abdun Nihaal <nihaal@xxxxxxxxxxxxxx>
---
Compile tested only. Issue found using static analysis.

drivers/firewire/core-topology.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/firewire/core-topology.c b/drivers/firewire/core-topology.c
index df2ac0dab106..317f8f57e521 100644
--- a/drivers/firewire/core-topology.c
+++ b/drivers/firewire/core-topology.c
@@ -227,6 +227,7 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self
(enumerator.quadlet_count > 0 && parent_count != 1)) {
fw_err(card, "parent port inconsistency for node %d: "
"parent_count=%d\n", phy_id, parent_count);
+ kfree(node);
return NULL;
}

--
2.43.0