genirq: Check __free_irq() return value for NULL
authorAlexandru Moise <00moses.alexander00@gmail.com>
Tue, 19 Sep 2017 20:04:12 +0000 (22:04 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 25 Sep 2017 14:40:31 +0000 (16:40 +0200)
__free_irq() can return a NULL irqaction for example when trying to free
already-free IRQ, but the callsite unconditionally dereferences the
returned pointer.

Fix this by adding a check and return NULL.

Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20170919200412.GA29985@gmail.com
kernel/irq/manage.c

index 573dc52b0806054bc485c1290d0ed58ccfbb5c87..d00132b5c325b389f6646de064527df64e2d873e 100644 (file)
@@ -1643,6 +1643,10 @@ const void *free_irq(unsigned int irq, void *dev_id)
 #endif
 
        action = __free_irq(irq, dev_id);
+
+       if (!action)
+               return NULL;
+
        devname = action->name;
        kfree(action);
        return devname;