Re: [PATCH 3/3] firewire: core: fix memory leak in error path of build_tree()

Takashi Sakamoto <[email protected]>
Newsgroups gmane.linux.kernel.firewire.devel,gmane.linux.kernel
Message-ID <[email protected]>
Hi,

On Wed, Aug 12, 2026 at 02:35:36PM +0530, Abdun Nihaal wrote:
> On Tue, Aug 11, 2026 at 09:09:28PM +0900, Takashi Sakamoto wrote:
> > In the error path of build_tree(), node instances can remain in the local
> > linked list when the function returns.
> > 
> > Whenever an invalid value is detected in the self ID sequence, each
> > allocated node instance is either an entry in the linked list or an
> > entry in the ports array of its parent node. Therefore, the allocate
> > node instances can be safely released by traversing the linked list from
> > its head.
> > 
> > Release the remaining node instances with for_each_fw_node() before
> > returning to the caller.
> > 
> > Fixes: 3038e353cfaf ("firewire: Add core firewire stack.")
> > Reported-by: Abdun Nihaal <[email protected]>
> > Link: https://lore.kernel.org/all/[email protected]/
> > Signed-off-by: Takashi Sakamoto <[email protected]>
> 
> Looks good to me. Thanks for fixing this.
> 
> I don't have a proper understanding of how the Firewire topology
> construction happens, and was a bit confused by how the node->color
> is used in the code, that's why I couldn't follow up with the fix.

Yea. How the color member of fw_node/fw_card works was unclear to me too.
Writing some KUnit tests finally brought it to me.

Anyway, thank for your pointing and working for the issue.


Regards

Takashi Sakamoto
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.