[PATCH 5.5 080/367] MIPS: SGI-IP30: Check for valid pointer before using it
From: Greg Kroah-Hartman
Date: Mon Feb 10 2020 - 07:51:44 EST
From: Thomas Bogendoerfer <tbogendoerfer@xxxxxxx>
commit c0e79fd89749b0cda1c72049e2772dd2eeada86f upstream.
Fix issue detected by Smatch:
./arch/mips/sgi-ip30/ip30-irq.c:236 heart_domain_free()
warn: variable dereferenced before check 'irqd' (see line 235)
Fixes: 7505576d1c1a ("MIPS: add support for SGI Octane (IP30)")
Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@xxxxxxx>
Signed-off-by: Paul Burton <paulburton@xxxxxxxxxx>
Cc: Ralf Baechle <ralf@xxxxxxxxxxxxxx>
Cc: James Hogan <jhogan@xxxxxxxxxx>
Cc: linux-mips@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: <stable@xxxxxxxxxxxxxxx> # v5.5+
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
arch/mips/sgi-ip30/ip30-irq.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/arch/mips/sgi-ip30/ip30-irq.c
+++ b/arch/mips/sgi-ip30/ip30-irq.c
@@ -232,9 +232,10 @@ static void heart_domain_free(struct irq
return;
irqd = irq_domain_get_irq_data(domain, virq);
- clear_bit(irqd->hwirq, heart_irq_map);
- if (irqd && irqd->chip_data)
+ if (irqd) {
+ clear_bit(irqd->hwirq, heart_irq_map);
kfree(irqd->chip_data);
+ }
}
static const struct irq_domain_ops heart_domain_ops = {