From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8E3C7CD98F1 for ; Wed, 17 Jun 2026 12:08:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Subject:Cc:To:From: Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1j3L783xN5tmnlQDQzKwqjETkSIJXUdm+vGp8MYnTFY=; b=UtYEaZYtCnNlA5nZqWkKOu3D4w zzVbr5q4uAnd/nTb4VGMiDY3DFoEv7kU1zk3G/7benGQ20LaW0rCi1alRPZAIApSZ+MP7hel0N61/ elUWjlnSVS5zvL38e9+ft8bgxL0fpD54u6bnmR5QKqnEsz9hMD6rYT3mkm38aPQfOOhD0M56Oj18s YNXQaQ21/H5XDkK5SYxD9UzO0/47zqHB45ohDXjQztDNkYJfUlUWDnCnwx/SibEYe/7zLyT3NE/P/ Q1AnMPZ6RXOSBUhSlfrWXeEdfyjWlEdxdskG3tJGcmz3naoJ5l/UyZGb4RkPp6IHRh4U/D32N3025 92yO1E+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wZp3m-0000000HIwc-0km4; Wed, 17 Jun 2026 12:07:58 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wZp3l-0000000HIwK-05mh for linux-arm-kernel@lists.infradead.org; Wed, 17 Jun 2026 12:07:57 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id C191643F3E; Wed, 17 Jun 2026 12:07:56 +0000 (UTC) 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) 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 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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.