rtc: sh: fix possible race condition
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 20 Mar 2019 11:30:09 +0000 (12:30 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Thu, 4 Apr 2019 08:07:09 +0000 (10:07 +0200)
commit1097998d27da39578542e79ff865b4d74e755cd0
treedbaf06cbb95fd81e353363c4a45c3bd8bb50f9c5
parent9852023d204b97324e7fa84f50f28a9d602b79fb
rtc: sh: fix possible race condition

The IRQ is requested before the struct rtc is allocated and registered, but
this struct is used in the IRQ handler. This may lead to a NULL pointer
dereference.

Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc
struct before requesting the IRQ.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-sh.c