| From 04287f135fe8fcde5efd9a6e67c93099aa7fb0ac Mon Sep 17 00:00:00 2001 | |
| From: Sasha Levin <sashal@kernel.org> | |
| Date: Tue, 3 Nov 2026 13:50:40 -0800 | |
| Subject: MIPS: SB1250: Validate and update IRQ affinity | |
| From: Florian Fainelli <f.fainelli@gmail.com> | |
| [ Upstream commit 456c965ca46c59a4a241c755e6565fd883a522f4 ] | |
| sb1250_set_affinity() selects the first online CPU in the requested | |
| affinity mask without checking whether such a CPU exists. If the | |
| intersection is empty, the resulting CPU index is invalid and must | |
| not be passed to cpu_logical_map(). | |
| Reject affinity masks containing no online CPU with -EINVAL before | |
| accessing the CPU mapping or interrupt mapper registers. | |
| Also update the effective affinity mask to reflect the single logical | |
| CPU selected as the interrupt target. | |
| Fixes: 421d1563c662 ("mips: Validate online cpus in irq_set_affinity() callbacks") | |
| Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> | |
| Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> | |
| Signed-off-by: Sasha Levin <sashal@kernel.org> | |
| --- | |
| arch/mips/sibyte/sb1250/irq.c | 3 +++ | |
| 1 file changed, 3 insertions(+) | |
| diff --git a/arch/mips/sibyte/sb1250/irq.c b/arch/mips/sibyte/sb1250/irq.c | |
| index 2f08ad267a11e..d7a656cd7ec0c 100644 | |
| --- a/arch/mips/sibyte/sb1250/irq.c | |
| +++ b/arch/mips/sibyte/sb1250/irq.c | |
| @@ -76,6 +76,8 @@ static int sb1250_set_affinity(struct irq_data *d, const struct cpumask *mask, | |
| unsigned long flags; | |
| i = cpumask_first_and(mask, cpu_online_mask); | |
| + if (i >= nr_cpu_ids) | |
| + return -EINVAL; | |
| /* Convert logical CPU to physical CPU */ | |
| cpu = cpu_logical_map(i); | |
| @@ -103,6 +105,7 @@ static int sb1250_set_affinity(struct irq_data *d, const struct cpumask *mask, | |
| ____raw_writeq(cur_ints, IOADDR(A_IMR_MAPPER(cpu) + | |
| R_IMR_INTERRUPT_MASK)); | |
| } | |
| + irq_data_update_effective_affinity(d, cpumask_of(i)); | |
| raw_spin_unlock_irqrestore(&sb1250_imr_lock, flags); | |
| return 0; | |
| -- | |
| 2.53.0 | |