x86/irq: Prevent force migration of irqs which are not in the vector domain
[firefly-linux-kernel-4.4.55.git] / arch / x86 / kernel / apic / vector.c
index df6b4eeac0bde402207f321491880edfb588ed77..0988e204f1e39424a08e8d50ff91440206bfc8a5 100644 (file)
@@ -659,11 +659,28 @@ void irq_complete_move(struct irq_cfg *cfg)
  */
 void irq_force_complete_move(struct irq_desc *desc)
 {
-       struct irq_data *irqdata = irq_desc_get_irq_data(desc);
-       struct apic_chip_data *data = apic_chip_data(irqdata);
-       struct irq_cfg *cfg = data ? &data->cfg : NULL;
+       struct irq_data *irqdata;
+       struct apic_chip_data *data;
+       struct irq_cfg *cfg;
        unsigned int cpu;
 
+       /*
+        * The function is called for all descriptors regardless of which
+        * irqdomain they belong to. For example if an IRQ is provided by
+        * an irq_chip as part of a GPIO driver, the chip data for that
+        * descriptor is specific to the irq_chip in question.
+        *
+        * Check first that the chip_data is what we expect
+        * (apic_chip_data) before touching it any further.
+        */
+       irqdata = irq_domain_get_irq_data(x86_vector_domain,
+                                         irq_desc_get_irq(desc));
+       if (!irqdata)
+               return;
+
+       data = apic_chip_data(irqdata);
+       cfg = data ? &data->cfg : NULL;
+
        if (!cfg)
                return;