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

Abdun Nihaal <[email protected]> Mon, 27 Jul 2026 15:29:53 +0530
Newsgroups gmane.linux.kernel,gmane.linux.kernel.firewire.devel,gmane.linux.kernel.stable
Message-ID <[email protected]>
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: [email protected]
Signed-off-by: Abdun Nihaal <[email protected]>
---
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