From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1548040F73B for ; Thu, 13 Aug 2026 11:39:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786621188; cv=none; b=TR+Nr97CnMs8DDliz25IkgroK+p3m9mtColssPIBABecU4ZNAlPDHCRdjbpVVVaUz/I3JK1RXKDM5mflDgZA95eJZnxcoQYAmLFGCbgQuL/8u2hqIsp/6BBQ0mSCwTfrGtsrYS5TWQtNI34dklNCJ2fZDaWnIjQJ6c3eZzooqW8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786621188; c=relaxed/simple; bh=e1VgM9zVsLtuayau3a4Mu7CJXH1BYp5DuWcFrObTr1c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SfFHN8umZ4lFmgLtSlizdt8LMgeZ8HEui9xVBKAPqyj6MgFCp9t9G/dLNNK6qTI8KTdzFjPOEavdE7dFsbj9FsWwH3QZRYX6lagOJ6YicKv2yEphjo0PZufI72YYpzoFdpmDWKupIScJu/AI6+/xifRR+G2tJywEwmCRlQiM6wU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp; spf=pass smtp.mailfrom=sakamocchi.jp; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b=t4Q8ToBP; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=mgYwLINo; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="t4Q8ToBP"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="mgYwLINo" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id D2E9A14000F0; Thu, 13 Aug 2026 07:39:44 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 13 Aug 2026 07:39:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1786621184; x= 1786707584; bh=W6t92yAsvWG6K3mfqLdjjQn8/FiguEYgeNbwjz2GbZc=; b=t 4Q8ToBPl6zLQjxQgA8RT29YmwKJ9YfP5wRYG8IAfpi0j243cg6BHRQtZrGb7CIeQ v81ye1AdL9luYb/JRApTWb/yzSdwT1Xv6iR2vddMlhiAoWReivPpHFu67Vv4Az1w B1HoHDa5kaH02ISQuC1mIR+24kmcNKKzvXRVtJXs5eSluq+e1QWsVxoA2q1TLnLv Ga3/J0tu0bQgjWVc3TfYBLUr1c9o/zRwxVf0m/WaIO+Og1YPveCrKy26Y/hRgglc 98VwYldxy++HdI8zxSPz+iuhH/qXMtDgka+cPmXQTjwdz1CTjyOQGTEE9D4o6I4Y ExWasUFCSgucw930+/e+g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl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u/1HYkpiwDJ//MMtr5 9z0KZ1mteybJh/30m6x+O66ffIdkHXsA+DuYZRkqVZj8IVowHVUAtUb9MMlg X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Aug 2026 07:39:42 -0400 (EDT) Date: Thu, 13 Aug 2026 20:39:40 +0900 From: Takashi Sakamoto 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() Message-ID: <20260813113940.GA738240@sakamocchi.jp> Mail-Followup-To: linux1394-devel@lists.sourceforge.net, nihaal@cse.iitm.ac.in, linux-kernel@vger.kernel.org References: <20260811120928.700577-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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