Skip to contentSkip to conversation

irqchip/tango: Fix possible null ptr reference in tangox_irq_init

PATCH In review Ye Bin 2 participants 2 messages Sep 3, 2020 irqchip drivers

lore
Share & tools
lore

Ye Bin

author
#0 lore raw

PATCH 1/1 irqchip/tango: Fix possible null ptr reference in tangox_irq_init

In tangox_irq_init allocate chip but not test.

---
 drivers/irqchip/irq-tango.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/irqchip/irq-tango.c +2 -0
index 34290f09b853..25da120230ad 100644
@@ -187,6 +187,8 @@ static int __init tangox_irq_init(void __iomem *base, struct resource *baseres,
 		panic("%pOFn: failed to get address", node);
 
 	chip = kzalloc(sizeof(*chip), GFP_KERNEL);
+	if (!chip)
+		panic("%pOFn: failed to get chip", node);
 	chip->ctl = res.start - baseres->start;
 	chip->base = base;
 
Signature · 1 line
2.25.4
#1 lore raw
Quoted 12 lines · Ye Bin

In tangox_irq_init allocate chip but not test.

---
 drivers/irqchip/irq-tango.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/irqchip/irq-tango.c +0 -0
index 34290f09b853..25da120230ad 100644

drivers/irqchip/irq-tango.c static int __init tangox_irq_init(void __iomem · line 194

Quoted 8 lines
drivers/irqchip/irq-tango.c +2 -0
@@ -187,6 +187,8 @@ static int __init tangox_irq_init(void __iomem
 *base, struct resource *baseres,
 		panic("%pOFn: failed to get address", node);
 
 	chip = kzalloc(sizeof(*chip), GFP_KERNEL);
+	if (!chip)
+		panic("%pOFn: failed to get chip", node);
 	chip->ctl = res.start - baseres->start;
 	chip->base = base;

So you are trading a panic for a panic? What is the point? A failing kzalloc already gives you all the information you may need.

        M.
Signature · 1 line
Jazz is not dead. It just smells funny...