diff mbox series

[6/6] x86/ioapic: Fix return check of __irq_domain_alloc_irqs

Message ID 20210102175859.335447-6-adam@l4re.org
State New
Headers show
Series [1/6] irqchip/bcm2836: Fix return check in IPI alloc | expand

Commit Message

Adam Lackorzynski Jan. 2, 2021, 5:58 p.m. UTC
0 is not a proper IRQ number and also indicates failure.
Also check for this case in upwards functions.

Signed-off-by: Adam Lackorzynski <adam@l4re.org>
---
 arch/x86/kernel/apic/io_apic.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Thomas Gleixner Jan. 27, 2021, 12:03 p.m. UTC | #1
On Sat, Jan 02 2021 at 18:58, Adam Lackorzynski wrote:
> 0 is not a proper IRQ number and also indicates failure.
> Also check for this case in upwards functions.

0 is a valid irq number for historical reasons on x86. So no.

Thanks,

        tglx
diff mbox series

Patch

diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index e4ab4804b20d..8ae46a092c88 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -1007,7 +1007,7 @@  static int alloc_isa_irq_from_domain(struct irq_domain *domain,
 		info->flags |= X86_IRQ_ALLOC_LEGACY;
 		irq = __irq_domain_alloc_irqs(domain, irq, 1, node, info, true,
 					      NULL);
-		if (irq >= 0) {
+		if (irq > 0) {
 			irq_data = irq_domain_get_irq_data(domain, irq);
 			data = irq_data->chip_data;
 			data->isa_irq = true;
@@ -1050,10 +1050,11 @@  static int mp_map_pin_to_irq(u32 gsi, int idx, int ioapic, int pin,
 			irq = alloc_irq_from_domain(domain, ioapic, gsi, &tmp);
 		else if (!mp_check_pin_attr(irq, &tmp))
 			irq = -EBUSY;
-		if (irq >= 0) {
+		if (irq > 0) {
 			data = irq_get_chip_data(irq);
 			data->count++;
-		}
+		} else if (irq == 0)
+			irq = -ENOENT;
 	}
 	mutex_unlock(&ioapic_mutex);