stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: pl031: fix rtc features null pointer dereference
@ 2022-02-25 16:19 Elliot Berman
  2022-03-08 16:41 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Elliot Berman @ 2022-02-25 16:19 UTC (permalink / raw)
  To: Linus Walleij, Alessandro Zummo, Alexandre Belloni
  Cc: Ali Pouladi, linux-arm-kernel, linux-rtc, linux-kernel,
	Carl van Schaik, stable, Elliot Berman

From: Ali Pouladi <quic_apouladi@quicinc.com>

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>
---
 drivers/rtc/rtc-pl031.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index e38ee8848385..bad6a5d9c683 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -350,9 +350,6 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
 		}
 	}
 
-	if (!adev->irq[0])
-		clear_bit(RTC_FEATURE_ALARM, ldata->rtc->features);
-
 	device_init_wakeup(&adev->dev, true);
 	ldata->rtc = devm_rtc_allocate_device(&adev->dev);
 	if (IS_ERR(ldata->rtc)) {
@@ -360,6 +357,9 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
 		goto out;
 	}
 
+	if (!adev->irq[0])
+		clear_bit(RTC_FEATURE_ALARM, ldata->rtc->features);
+
 	ldata->rtc->ops = ops;
 	ldata->rtc->range_min = vendor->range_min;
 	ldata->rtc->range_max = vendor->range_max;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rtc: pl031: fix rtc features null pointer dereference
  2022-02-25 16:19 [PATCH] rtc: pl031: fix rtc features null pointer dereference Elliot Berman
@ 2022-03-08 16:41 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2022-03-08 16:41 UTC (permalink / raw)
  To: Alessandro Zummo, Linus Walleij, Elliot Berman
  Cc: Alexandre Belloni, linux-kernel, linux-arm-kernel, linux-rtc,
	stable, Carl van Schaik, Ali Pouladi

On Fri, 25 Feb 2022 08:19:24 -0800, Elliot Berman wrote:
> From: Ali Pouladi <quic_apouladi@quicinc.com>
> 
> 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.
> 
> [...]

Applied, thanks!

[1/1] rtc: pl031: fix rtc features null pointer dereference
      commit: 75445c15916421993d47c338a17d49f3449b516f

Best regards,
-- 
Alexandre Belloni <alexandre.belloni@bootlin.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-08 16:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-25 16:19 [PATCH] rtc: pl031: fix rtc features null pointer dereference Elliot Berman
2022-03-08 16:41 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).