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 790BB3C4154 for ; Wed, 17 Jun 2026 12:09:53 +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=1781698194; cv=none; b=a7fEIGh+TgAG6uJqvdmo+4rOnTlgCkJzVOXzdpIg/ZXwzB8QOszF7PqGf7Tfyw6frMw4Pf10kTfyaAvSZ5S002EV36lOT7uJDPz6IhnrYkv1TQmA/ObHuOJdSjPfKLuIyWqNvJEeiBr1r8WdhI6B8dXiAMT0HfTxc0gRD278WKs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781698194; c=relaxed/simple; bh=MZBAEIU517sZeF7bx9fdF8gXj1AFhLf13Thc7va90Kg=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=sVz/6B7sAS6IaURLuOO8cE5Kgv5RN+P/7+qGreGVmjlvQpLo1RLHZUoNq4Hu0mXv47wwYBN/8EPyJ/FtyQ1B8yWX8rcnaApFdA08MfyMJktDsXXYYxvtTqYeqseJfYNpyvJtlIVf4UvlmWxLTQEG2nQEVAFO8h5vYY8Z5aI+kLg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dyCtHVxv; 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="dyCtHVxv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11A271F00A3A; Wed, 17 Jun 2026 12:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781698193; bh=jdxmBgV7xIk2aU1yR0qr5KSK2tuwAbIYHWip0SjnY18=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=dyCtHVxvxG5jAeXkN7iA355KwPGzIsH9XJysaSLabhSbcYDbhpdagUM5W+u50DbGO lhxKNVk+kOCOk5mLql0rAbtXWXbx9m6ssuzHx35lQ9KoDIEOpJmq57OH2OLGz0uhlV 4fWZOLiYbGRTEShiop7tRvzv0oVMtJkwTbZN63GgF+ukeiFbXB/gXKz8Yjd6PKlHpi Lbr82J9x2goCzUEStqA/vr58w5NAiJt/sxKcUnYdh1rtupOpl3j/IEVAbSOgR6VUE2 8BhAHK9g9iiQdHCNF6DdpKY+uQmZUs104hXIgko1/rN/x+3SuS7mzhAvXIEHQqOo2A eKz8Ym76YY2fw== 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 1wZp5b-0000000Dfi2-1WrG; Wed, 17 Jun 2026 12:09:51 +0000 Date: Wed, 17 Jun 2026 13:09:51 +0100 Message-ID: <86y0gds700.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 1/6] irqchip/gic-v3-its: Fix LPI range leak and refactor error handler in its_lpi_alloc() In-Reply-To: References: <20260615032910.54735-1-shikemeng@huaweicloud.com> <20260615032910.54735-2-shikemeng@huaweicloud.com> <87jys089sn.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:31:22 +0100, Kemeng Shi wrote: >=20 > =E5=9C=A8 2026/6/15 16:52:56, Marc Zyngier =E5=86=99=E9=81=93: > > On Mon, 15 Jun 2026 04:29:05 +0100, > > Kemeng Shi wrote: > >> > >> Fix the LIP range leak when bitmap_zalloc() failed. Besides refactor > >=20 > > Typo. > >=20 > >> error handling code to make it a little simpler. > >=20 > > No. Please don't mix fixes and (totally pointless) refactoring. > OK, I will only keep fix in this patch.>=20 > >> > >> Signed-off-by: Kemeng Shi > >> --- > >> drivers/irqchip/irq-gic-v3-its.c | 21 +++++++++------------ > >> 1 file changed, 9 insertions(+), 12 deletions(-) > >> > >> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gi= c-v3-its.c > >> index 291d7668cc8d..2b7b546c43c8 100644 > >> --- a/drivers/irqchip/irq-gic-v3-its.c > >> +++ b/drivers/irqchip/irq-gic-v3-its.c > >> @@ -2217,10 +2217,9 @@ static int __init its_lpi_init(u32 id_bits) > >> static unsigned long *its_lpi_alloc(int nr_irqs, u32 *base, int *nr_i= ds) > >> { > >> unsigned long *bitmap =3D NULL; > >> - int err =3D 0; > >> =20 > >> do { > >> - err =3D alloc_lpi_range(nr_irqs, base); > >> + int err =3D alloc_lpi_range(nr_irqs, base); > >> if (!err) > >> break; > >> =20 > >> @@ -2228,22 +2227,20 @@ static unsigned long *its_lpi_alloc(int nr_irq= s, u32 *base, int *nr_ids) > >> } while (nr_irqs > 0); > >> =20 > >> if (!nr_irqs) > >> - err =3D -ENOSPC; > >> - > >> - if (err) > >> - goto out; > >> + goto err_out; > >> =20 > >> bitmap =3D bitmap_zalloc(nr_irqs, GFP_ATOMIC); > >> if (!bitmap) > >> - goto out; > >> + goto err_free_lpi; > >> =20 > >> *nr_ids =3D nr_irqs; > >> - > >> -out: > >> - if (!bitmap) > >> - *base =3D *nr_ids =3D 0; > >> - > >> return bitmap; > >> + > >> +err_free_lpi: > >> + free_lpi_range(*base, nr_irqs); > >> +err_out: > >> + *base =3D *nr_ids =3D 0; > >> + return NULL; > >> } > >> =20 > >> static void its_lpi_free(unsigned long *bitmap, u32 base, u32 nr_ids) > >=20 > > Honestly, I question the validity of handling errors this way. You are > > already unable to allocate a per-device bitmap. And yet you are > > calling free_lpi_range(), which has the interesting property of > > *allocating* memory. Which you don't have. Oh wait... > You are right. I'm considering use xarray to track the lpi range or > modify free_lpi_range to try merge first before memory allocation. > What would you recommend? My personal take on this is that leaking a few LPIs is not a big deal, given how many we have. You are trying to optimise for an error case that never happens, and I really don't want to add more complexity to this. M. --=20 Without deviation from the norm, progress is not possible.