[PATCH 3/3] irqchip/gic-v5: Fix error handling in gicv5_its_irq_domain_alloc()

Dan Carpenter dan.carpenter at linaro.org
Thu Jul 17 07:41:06 PDT 2025


On Thu, Jul 17, 2025 at 11:25:15AM +0200, Lorenzo Pieralisi wrote:
> On Wed, Jul 16, 2025 at 02:38:22PM -0500, Dan Carpenter wrote:
> > There are two issues to fix in this code:
> > 1) If gicv5_alloc_lpi() fails the original code was checking the wrong
> > variable.  Fix the mixup between "ret" and "lpi".
> > 2) If irq_domain_alloc_irqs_parent() fails, then clean up all the loop
> > iterations instead of just the current iteration.
> > 
> > Fixes: 57d72196dfc8 ("irqchip/gic-v5: Add GICv5 ITS support")
> > Signed-off-by: Dan Carpenter <dan.carpenter at linaro.org>
> > ---
> >  drivers/irqchip/irq-gic-v5-its.c | 14 +++++++++++---
> >  1 file changed, 11 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/irqchip/irq-gic-v5-its.c b/drivers/irqchip/irq-gic-v5-its.c
> > index 55360ae9f1f6..8cc8563e27d5 100644
> > --- a/drivers/irqchip/irq-gic-v5-its.c
> > +++ b/drivers/irqchip/irq-gic-v5-its.c
> > @@ -949,15 +949,18 @@ static int gicv5_its_irq_domain_alloc(struct irq_domain *domain, unsigned int vi
> >  	device_id = its_dev->device_id;
> >  
> >  	for (i = 0; i < nr_irqs; i++) {
> > -		lpi = gicv5_alloc_lpi();
> > +		ret = gicv5_alloc_lpi();
> >  		if (ret < 0) {
> >  			pr_debug("Failed to find free LPI!\n");
> >  			goto out_eventid;
> 
> This should be:
> 
> goto out_free_lpi;
> 

Yes, you're right.

> otherwise we miss cleaning up for [0, i - 1] on LPI alloc failure.
> 
> I can fix it up - not sure it is worth splitting it into two patches,
> just let me know please how you want me to handle it.

I don't think it should be split up.  As a reviewer I would be annoyed
by a split up version of this.

I'm a little bit surprised by the offer to fix it up for me...  Is this
going through your tree?  It's probably easiest if I just send a v2...
Let me do that.

regards,
dan carpenter




More information about the linux-arm-kernel mailing list