From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 069CC17A2FC for ; Wed, 17 Jun 2026 12:07:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781698078; cv=none; b=EZqtUUCps6wssaWn9++Vvge47hM70B2Ezj8LPVlqATcM3NZiDwd+UUnNT96jAg68jbTcnMGq/dwy211WY2S8ZdKJ1DhPb8PK5mWPmXA3TRxAIQgnDvNJBQgcb6WD+kVbcPyWpHsaMAWQdc8EYjBCpmatCbRUTb6fjLJIU/8Eneo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781698078; c=relaxed/simple; bh=cZWpkx8Rz4KXY3B5zBeHHKVLhEZk4r6dqkQQ46aDnhs=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=LNTuxbPzahrcXtTBxBAOuaiV9VQP8Cg7TKmxQWcEKIuxTc9l0o0hljuy4xVMpYRY2bwYwmdbV5usn66RvbtnQ/Vanfpo/EcconC21ArmxNTpyDjV5cEKqtmEEoMGwzLywoXOXYWP2zVUA1YL+EuCZx/Jh6YMmoWiw8bCvHcoiCg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TZSbXhY0; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TZSbXhY0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A45DD1F00A3D; Wed, 17 Jun 2026 12:07:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781698076; bh=1j3L783xN5tmnlQDQzKwqjETkSIJXUdm+vGp8MYnTFY=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=TZSbXhY0660q6khj5w+1+nUtCVJlCkkF6rfC7kgOt6X43Weow9Jyj6LHChJkfJ1ua NFo3PpKelYmAiXYxDHZid2Jz4m8LK5aD7nnlOH1kE6i9ZH76Fu7QNg/iv6/hFg9n8X rmqFajlYYeDF3JfOe/pQdQhrPy85nJX7eMxWsgXderOebSEGvpPbpZiZ4GJNm7lZRa u15LkcC0qhhTY45qPxDZ1e64ASgTWwzzKjbSXERIM6BwlUbixy4PDymXnJFT0Aoxdr G7UCmAn0k8uNh7tpoqQV8atly8jRtp7OH1PjaZ3c2VpXwGffCcy5Msf8M9OI4Gq19c MCNhZR5PRAM4A== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wZp3i-0000000Dfe5-3dDR; Wed, 17 Jun 2026 12:07:54 +0000 Date: Wed, 17 Jun 2026 13:07:54 +0100 Message-ID: <86zf0ts739.wl-maz@kernel.org> From: Marc Zyngier To: Kemeng Shi Cc: tglx@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/6] irqchip/gic-v3-its: Fix memleak in its_probe_one() In-Reply-To: References: <20260615032910.54735-1-shikemeng@huaweicloud.com> <20260615032910.54735-3-shikemeng@huaweicloud.com> <87ik7k89i5.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: shikemeng@huaweicloud.com, tglx@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Tue, 16 Jun 2026 02:39:10 +0100, Kemeng Shi wrote: >=20 > =E5=9C=A8 2026/6/15 16:59:14, Marc Zyngier =E5=86=99=E9=81=93: > > On Mon, 15 Jun 2026 04:29:06 +0100, > > Kemeng Shi wrote: > >> > >> Fix collection leak when its_init_domain() failed in its_probe_one(). > >> > >> Signed-off-by: Kemeng Shi > >> --- > >> drivers/irqchip/irq-gic-v3-its.c | 10 +++++++++- > >> 1 file changed, 9 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gi= c-v3-its.c > >> index 2b7b546c43c8..df26ddc97ae2 100644 > >> --- a/drivers/irqchip/irq-gic-v3-its.c > >> +++ b/drivers/irqchip/irq-gic-v3-its.c > >> @@ -3032,6 +3032,12 @@ static int its_alloc_collections(struct its_nod= e *its) > >> return 0; > >> } > >> =20 > >> +static void its_free_collections(struct its_node *its) > >> +{ > >> + kfree(its->collections); > >> + its->collections =3D NULL; > >> +} > >=20 > > Why do we need an extra helper for something that has a single calling > > spot? Why is it important to set collections to NULL, given that we're > > about to free the structure without even looking further? > >=20 > The extra helper is added for symmetry with its_alloc_collections(), keep= ing > allocation/deallocation logic paired. But there is zero logic here. None. it is a call to kfree(), just that, and we don't need any additional abstraction. > In this way, we need to only modified > allocation/deallocation function if more member is added for collections. Well, when we get there, we can always add an abstraction. > Setting collections to NULL is a personal habit to quickly catch use-afte= r-free > of collections. Could drop this which is not that import. I don't see the point of doing that. M. --=20 Without deviation from the norm, progress is not possible.