Thread (11 messages) 11 messages, 5 authors, 2021-01-27
STALE1961d

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

From: Adam Lackorzynski <hidden>
Date: 2021-01-02 18:20:01
Also in: linux-arm-kernel
Subsystem: the rest, x86 architecture (32-bit and 64-bit) · Maintainers: Linus Torvalds, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen

0 is not a proper IRQ number and also indicates failure.
Also check for this case in upwards functions.

Signed-off-by: Adam Lackorzynski <redacted>
---
 arch/x86/kernel/apic/io_apic.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
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);
 
-- 
2.30.0.rc2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help