thermal: rcar: Fix race condition between init and interrupt
authorGeert Uytterhoeven <geert+renesas@glider.be>
Mon, 23 Feb 2015 15:37:24 +0000 (16:37 +0100)
committerEduardo Valentin <edubezval@gmail.com>
Tue, 24 Feb 2015 18:56:42 +0000 (14:56 -0400)
commit0b37a83a91e885250c68546ce7271ce722120c99
tree30af05e3cf65ae0ca9ecca44f02a473c55a40e2a
parent12ca7188468ee29c4e717f73db4bf43c90954fc7
thermal: rcar: Fix race condition between init and interrupt

As soon as the interrupt has been enabled by devm_request_irq(), the
interrupt routine may be called, depending on the current status of the
hardware.

However, at that point rcar_thermal_common hasn't been initialized
complely yet. E.g. rcar_thermal_common.base is still NULL, causing a
NULL pointer dereference:

    Unable to handle kernel NULL pointer dereference at virtual address 0000000c
    pgd = c0004000
    [0000000c] *pgd=00000000
    Internal error: Oops: 5 [#1] SMP ARM
    CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.19.0-rc7-ape6evm-04564-gb6e46cb7cbe82389 #30
    Hardware name: Generic R8A73A4 (Flattened Device Tree)
    task: ee8953c0 ti: ee896000 task.ti: ee896000
    PC is at rcar_thermal_irq+0x1c/0xf0
    LR is at _raw_spin_lock_irqsave+0x48/0x54

Postpone the call to devm_request_irq() until all initialization has
been done to fix this.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
drivers/thermal/rcar_thermal.c