rtc: ds1374: fix possible race condition
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Fri, 6 Mar 2020 07:34:01 +0000 (08:34 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Mon, 16 Mar 2020 10:12:10 +0000 (11:12 +0100)
commitc11af8131a4e7ba1960faed731ee7e84c2c13c94
treeac8645196ed47c8c7c8cfe718a53449bfe004c5a
parentd238df15e5cdfae54688ed9c1b33e19ed747dcda
rtc: ds1374: fix possible race condition

The RTC IRQ is requested before the struct rtc_device is allocated,
this may lead to a NULL pointer dereference in the IRQ handler.

To fix this issue, allocating the rtc_device struct before requesting
the RTC IRQ using devm_rtc_allocate_device, and use rtc_register_device
to register the RTC device.

Link: https://lore.kernel.org/r/20200306073404.56921-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-ds1374.c