[PATCH] genirq: fixup checks against nr_cpu_ids

From: Alexey Dobriyan
Date: Sat Aug 19 2017 - 05:58:04 EST


Valid CPU ids are [0, nr_cpu_ids-1] inclusive.

Signed-off-by: Alexey Dobriyan <adobriyan@xxxxxxxxx>
---

kernel/irq/ipi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--- a/kernel/irq/ipi.c
+++ b/kernel/irq/ipi.c
@@ -165,7 +165,7 @@ irq_hw_number_t ipi_get_hwirq(unsigned int irq, unsigned int cpu)
struct irq_data *data = irq_get_irq_data(irq);
struct cpumask *ipimask = data ? irq_data_get_affinity_mask(data) : NULL;

- if (!data || !ipimask || cpu > nr_cpu_ids)
+ if (!data || !ipimask || cpu >= nr_cpu_ids)
return INVALID_HWIRQ;

if (!cpumask_test_cpu(cpu, ipimask))
@@ -195,7 +195,7 @@ static int ipi_send_verify(struct irq_chip *chip, struct irq_data *data,
if (!chip->ipi_send_single && !chip->ipi_send_mask)
return -EINVAL;

- if (cpu > nr_cpu_ids)
+ if (cpu >= nr_cpu_ids)
return -EINVAL;

if (dest) {