irqchip/ti-sci-inta: Fix kernel crash if irq_create_fwspec_mapping fail
authorPeter Ujfalusi <peter.ujfalusi@ti.com>
Tue, 4 Jun 2019 10:17:51 +0000 (13:17 +0300)
committerMarc Zyngier <marc.zyngier@arm.com>
Wed, 5 Jun 2019 08:35:11 +0000 (09:35 +0100)
irq_create_fwspec_mapping() can fail, returning 0 as parent_virq. In this
case vint_desc is going to be NULL in ti_sci_inta_alloc_irq() which will
cause NULL pointer dereference.

Also note that irq_create_fwspec_mapping() returns 'unsigned int' so the
check '<=' was wrong.

Use -EINVAL if irq_create_fwspec_mapping() returned with 0.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
drivers/irqchip/irq-ti-sci-inta.c

index 011b60a49e3f94ccea763b09021d6de81f0831fc..ef4d625d2d806fcfe0f594db0c9467aba40fd76a 100644 (file)
@@ -159,9 +159,9 @@ static struct ti_sci_inta_vint_desc *ti_sci_inta_alloc_parent_irq(struct irq_dom
        parent_fwspec.param[1] = vint_desc->vint_id;
 
        parent_virq = irq_create_fwspec_mapping(&parent_fwspec);
-       if (parent_virq <= 0) {
+       if (parent_virq == 0) {
                kfree(vint_desc);
-               return ERR_PTR(parent_virq);
+               return ERR_PTR(-EINVAL);
        }
        vint_desc->parent_virq = parent_virq;