rtc: snvs: fix possible race condition
authorAnson Huang <Anson.Huang@nxp.com>
Tue, 16 Jul 2019 07:18:58 +0000 (15:18 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 7 Oct 2019 16:57:11 +0000 (18:57 +0200)
commit607f95788fa94d15538ffdf6bbfa53eb3af2cfa6
treefbdb0ff7a7a857565a2695c4a540ed3ffefd7c8b
parent078937549f47a933aa8039acfa36b325e8090ecb
rtc: snvs: fix possible race condition

[ Upstream commit 6fd4fe9b496d9ba3382992ff4fde3871d1b6f63d ]

The RTC IRQ is requested before the struct rtc_device is allocated,
this may lead to a NULL pointer dereference in 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.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
Link: https://lore.kernel.org/r/20190716071858.36750-1-Anson.Huang@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/rtc/rtc-snvs.c