rtc: pl031: fix rtc features null pointer dereference
authorAli Pouladi <quic_apouladi@quicinc.com>
Fri, 25 Feb 2022 16:19:24 +0000 (08:19 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:22:56 +0000 (14:22 +0200)
commitcd2722e411e8ab7e5ae41102f6925fa13dffdac5
tree53c0b7999061065576f2c1cfea39aebac5df0eb9
parent8e167fdd4f625572666b566fd29e8ef79566fece
rtc: pl031: fix rtc features null pointer dereference

commit ea6af39f3da50c86367a71eb3cc674ade3ed244c upstream.

When there is no interrupt line, rtc alarm feature is disabled.

The clearing of the alarm feature bit was being done prior to allocations
of ldata->rtc device, resulting in a null pointer dereference.

Clear RTC_FEATURE_ALARM after the rtc device is allocated.

Fixes: d9b0dd54a194 ("rtc: pl031: use RTC_FEATURE_ALARM")
Cc: stable@vger.kernel.org
Signed-off-by: Ali Pouladi <quic_apouladi@quicinc.com>
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20220225161924.274141-1-quic_eberman@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/rtc/rtc-pl031.c