All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtc: pxa: fix null pointer dereference
@ 2022-01-01 15:41 Laurence de Bruxelles
  2022-01-05  0:05 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Laurence de Bruxelles @ 2022-01-01 15:41 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Robert Jarzmik, linux-rtc, Laurence de Bruxelles

With the latest stable kernel versions the rtc on the PXA based
Zaurus does not work, when booting I see the following kernel messages:

pxa-rtc pxa-rtc: failed to find rtc clock source
pxa-rtc pxa-rtc: Unable to init SA1100 RTC sub-device
pxa-rtc: probe of pxa-rtc failed with error -2
hctosys: unable to open rtc device (rtc0)

I think this is because commit f2997775b111 ("rtc: sa1100: fix possible
race condition") moved the allocation of the rtc_device struct out of
sa1100_rtc_init and into sa1100_rtc_probe. This means that pxa_rtc_probe
also needs to do allocation for the rtc_device struct, otherwise
sa1100_rtc_init will try to dereference a null pointer. This patch adds
that allocation by copying how sa1100_rtc_probe in
drivers/rtc/rtc-sa1100.c does it; after the IRQs are set up a managed
rtc_device is allocated.

I've tested this patch with `qemu-system-arm -machine akita` and with a
real Zaurus SL-C1000 applied to 4.19, 5.4, and 5.10.

Signed-off-by: Laurence de Bruxelles <lfdebrux@gmail.com>
Fixes: f2997775b111 ("rtc: sa1100: fix possible race condition")
---
 drivers/rtc/rtc-pxa.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c
index d2f1d8f754bf..cf8119b6d320 100644
--- a/drivers/rtc/rtc-pxa.c
+++ b/drivers/rtc/rtc-pxa.c
@@ -330,6 +330,10 @@ static int __init pxa_rtc_probe(struct platform_device *pdev)
 	if (sa1100_rtc->irq_alarm < 0)
 		return -ENXIO;
 
+	sa1100_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(sa1100_rtc->rtc))
+		return PTR_ERR(sa1100_rtc->rtc);
+
 	pxa_rtc->base = devm_ioremap(dev, pxa_rtc->ress->start,
 				resource_size(pxa_rtc->ress));
 	if (!pxa_rtc->base) {
-- 
2.34.1


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

* Re: [PATCH] rtc: pxa: fix null pointer dereference
  2022-01-01 15:41 [PATCH] rtc: pxa: fix null pointer dereference Laurence de Bruxelles
@ 2022-01-05  0:05 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2022-01-05  0:05 UTC (permalink / raw)
  To: Laurence de Bruxelles; +Cc: Alexandre Belloni, linux-rtc, Robert Jarzmik

On Sat, 1 Jan 2022 15:41:49 +0000, Laurence de Bruxelles wrote:
> With the latest stable kernel versions the rtc on the PXA based
> Zaurus does not work, when booting I see the following kernel messages:
> 
> pxa-rtc pxa-rtc: failed to find rtc clock source
> pxa-rtc pxa-rtc: Unable to init SA1100 RTC sub-device
> pxa-rtc: probe of pxa-rtc failed with error -2
> hctosys: unable to open rtc device (rtc0)
> 
> [...]

Applied, thanks!

[1/1] rtc: pxa: fix null pointer dereference
      commit: 34127b3632b21e5c391756e724b1198eb9917981

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

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

end of thread, other threads:[~2022-01-05  0:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-01 15:41 [PATCH] rtc: pxa: fix null pointer dereference Laurence de Bruxelles
2022-01-05  0:05 ` Alexandre Belloni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.