diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2016-09-02 08:45:19 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2016-09-02 12:06:49 -0400 |
commit | fc590c22f9f056ab50190b797f6cacead29f9b75 (patch) | |
tree | 87719f60da441d05d0ea7f16fb3ba4d926491f5f | |
parent | eb0dc47ab6810c432e8193beccd9905ba0db8b22 (diff) |
genirq: Robustify handle_percpu_devid_irq()
The percpu_devid handler is not robust against spurious interrupts. If a
spurious interrupt happens and no action is installed then the handler
crashes with a NULL pointer dereference.
Add a sanity check for this and log the wreckage once in dmesg.
Reported-by: Majun <majun258@huawei.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: guohanjun@huawei.com
Cc: dingtianhong@huawei.com
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1609021436160.5647@nanos
-rw-r--r-- | kernel/irq/chip.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index b4c1bc7c9ca2..93c373a8b12b 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c | |||
@@ -756,7 +756,6 @@ void handle_percpu_devid_irq(struct irq_desc *desc) | |||
756 | { | 756 | { |
757 | struct irq_chip *chip = irq_desc_get_chip(desc); | 757 | struct irq_chip *chip = irq_desc_get_chip(desc); |
758 | struct irqaction *action = desc->action; | 758 | struct irqaction *action = desc->action; |
759 | void *dev_id = raw_cpu_ptr(action->percpu_dev_id); | ||
760 | unsigned int irq = irq_desc_get_irq(desc); | 759 | unsigned int irq = irq_desc_get_irq(desc); |
761 | irqreturn_t res; | 760 | irqreturn_t res; |
762 | 761 | ||
@@ -765,9 +764,20 @@ void handle_percpu_devid_irq(struct irq_desc *desc) | |||
765 | if (chip->irq_ack) | 764 | if (chip->irq_ack) |
766 | chip->irq_ack(&desc->irq_data); | 765 | chip->irq_ack(&desc->irq_data); |
767 | 766 | ||
768 | trace_irq_handler_entry(irq, action); | 767 | if (likely(action)) { |
769 | res = action->handler(irq, dev_id); | 768 | trace_irq_handler_entry(irq, action); |
770 | trace_irq_handler_exit(irq, action, res); | 769 | res = action->handler(irq, raw_cpu_ptr(action->percpu_dev_id)); |
770 | trace_irq_handler_exit(irq, action, res); | ||
771 | } else { | ||
772 | unsigned int cpu = smp_processor_id(); | ||
773 | bool enabled = cpumask_test_cpu(cpu, desc->percpu_enabled); | ||
774 | |||
775 | if (enabled) | ||
776 | irq_percpu_disable(desc, cpu); | ||
777 | |||
778 | pr_err_once("Spurious%s percpu IRQ%u on CPU%u\n", | ||
779 | enabled ? " and unmasked" : "", irq, cpu); | ||
780 | } | ||
771 | 781 | ||
772 | if (chip->irq_eoi) | 782 | if (chip->irq_eoi) |
773 | chip->irq_eoi(&desc->irq_data); | 783 | chip->irq_eoi(&desc->irq_data); |