Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Kemeng Shi <shikemeng@huaweicloud.com>
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()
Date: Mon, 15 Jun 2026 09:52:56 +0100	[thread overview]
Message-ID: <87jys089sn.wl-maz@kernel.org> (raw)
In-Reply-To: <20260615032910.54735-2-shikemeng@huaweicloud.com>

On Mon, 15 Jun 2026 04:29:05 +0100,
Kemeng Shi <shikemeng@huaweicloud.com> wrote:
> 
> Fix the LIP range leak when bitmap_zalloc() failed. Besides refactor

Typo.

> error handling code to make it a little simpler.

No. Please don't mix fixes and (totally pointless) refactoring.

> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
>  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-gic-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_ids)
>  {
>  	unsigned long *bitmap = NULL;
> -	int err = 0;
>  
>  	do {
> -		err = alloc_lpi_range(nr_irqs, base);
> +		int err = alloc_lpi_range(nr_irqs, base);
>  		if (!err)
>  			break;
>  
> @@ -2228,22 +2227,20 @@ static unsigned long *its_lpi_alloc(int nr_irqs, u32 *base, int *nr_ids)
>  	} while (nr_irqs > 0);
>  
>  	if (!nr_irqs)
> -		err = -ENOSPC;
> -
> -	if (err)
> -		goto out;
> +		goto err_out;
>  
>  	bitmap = bitmap_zalloc(nr_irqs, GFP_ATOMIC);
>  	if (!bitmap)
> -		goto out;
> +		goto err_free_lpi;
>  
>  	*nr_ids = nr_irqs;
> -
> -out:
> -	if (!bitmap)
> -		*base = *nr_ids = 0;
> -
>  	return bitmap;
> +
> +err_free_lpi:
> +	free_lpi_range(*base, nr_irqs);
> +err_out:
> +	*base = *nr_ids = 0;
> +	return NULL;
>  }
>  
>  static void its_lpi_free(unsigned long *bitmap, u32 base, u32 nr_ids)

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...

	M.

-- 
Jazz isn't dead. It just smells funny.


  reply	other threads:[~2026-06-15  8:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15  3:29 [PATCH 0/6] Some random fixes and cleanups to irqchip/gic-v3-its Kemeng Shi
2026-06-15  3:29 ` [PATCH 1/6] irqchip/gic-v3-its: Fix LPI range leak and refactor error handler in its_lpi_alloc() Kemeng Shi
2026-06-15  8:52   ` Marc Zyngier [this message]
2026-06-15  3:29 ` [PATCH 2/6] irqchip/gic-v3-its: Fix memleak in its_probe_one() Kemeng Shi
2026-06-15  8:59   ` Marc Zyngier
2026-06-15  3:29 ` [PATCH 3/6] irqchip/gic-v3-its: Fix its node leak in gic_acpi_parse_madt_its() Kemeng Shi
2026-06-15  3:29 ` [PATCH 4/6] irqchip/gic-v3-its: Add ITS address info in more error logs Kemeng Shi
2026-06-15  9:01   ` Marc Zyngier
2026-06-15  3:29 ` [PATCH 5/6] irqchip/gic-v3-its: fix typo in comments Kemeng Shi
2026-06-15  9:03   ` Marc Zyngier
2026-06-15  3:29 ` [PATCH 6/6] irqchip/gic-v3-its: some minor cleanups Kemeng Shi
2026-06-15  9:14   ` Marc Zyngier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87jys089sn.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shikemeng@huaweicloud.com \
    --cc=tglx@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox