rtc: 88pm860x: fix possible race condition
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 11 Mar 2020 22:39:51 +0000 (23:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Apr 2020 08:36:31 +0000 (10:36 +0200)
commit66bfacd0f3021d9911a3bfc62d90ab7a1d207fa6
treeba620a39735b6a4d2de9920ded2819543fd7d64e
parent56aaa0e8c92a5262e5bde7057972080e8b2f17d6
rtc: 88pm860x: fix possible race condition

[ Upstream commit 9cf4789e6e4673d0b2c96fa6bb0c35e81b43111a ]

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.

Also remove the unnecessary error message as the core already prints the
info.

Link: https://lore.kernel.org/r/20200311223956.51352-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/rtc/rtc-88pm860x.c