Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

irqchip/gic-v5: Fix error handling in gicv5_its_irq_domain_alloc()

Code in gicv5_its_irq_domain_alloc() has two issues:

- it checks the wrong return value/variable when calling gicv5_alloc_lpi()

- The cleanup code does not take previous loop iterations into account

Fix both issues at once by adding the right gicv5_alloc_lpi() variable
check and by reworking the function cleanup code to take into account
current and previous iterations.

[ lpieralisi: Reworded commit message ]

Fixes: 57d72196dfc8 ("irqchip/gic-v5: Add GICv5 ITS support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>
Link: https://lore.kernel.org/all/20250908082745.113718-4-lpieralisi@kernel.org

authored by

Dan Carpenter and committed by
Thomas Gleixner
a186120c bfcd1fda

+14 -6
+14 -6
drivers/irqchip/irq-gic-v5-its.c
··· 947 947 device_id = its_dev->device_id; 948 948 949 949 for (i = 0; i < nr_irqs; i++) { 950 - lpi = gicv5_alloc_lpi(); 950 + ret = gicv5_alloc_lpi(); 951 951 if (ret < 0) { 952 952 pr_debug("Failed to find free LPI!\n"); 953 - goto out_eventid; 953 + goto out_free_irqs; 954 954 } 955 + lpi = ret; 955 956 956 957 ret = irq_domain_alloc_irqs_parent(domain, virq + i, 1, &lpi); 957 - if (ret) 958 - goto out_free_lpi; 958 + if (ret) { 959 + gicv5_free_lpi(lpi); 960 + goto out_free_irqs; 961 + } 959 962 960 963 /* 961 964 * Store eventid and deviceid into the hwirq for later use. ··· 978 975 979 976 return 0; 980 977 981 - out_free_lpi: 982 - gicv5_free_lpi(lpi); 978 + out_free_irqs: 979 + while (--i >= 0) { 980 + irqd = irq_domain_get_irq_data(domain, virq + i); 981 + gicv5_free_lpi(irqd->parent_data->hwirq); 982 + irq_domain_reset_irq_data(irqd); 983 + irq_domain_free_irqs_parent(domain, virq + i, 1); 984 + } 983 985 out_eventid: 984 986 gicv5_its_free_eventid(its_dev, event_id_base, nr_irqs); 985 987 return ret;