Skip to content

Commit 34127b3

Browse files
lfdebruxalexandrebelloni
authored andcommitted
rtc: pxa: fix null pointer dereference
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 f299777 ("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 <[email protected]> Fixes: f299777 ("rtc: sa1100: fix possible race condition") Signed-off-by: Alexandre Belloni <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 05020a7 commit 34127b3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/rtc/rtc-pxa.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ static int __init pxa_rtc_probe(struct platform_device *pdev)
330330
if (sa1100_rtc->irq_alarm < 0)
331331
return -ENXIO;
332332

333+
sa1100_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
334+
if (IS_ERR(sa1100_rtc->rtc))
335+
return PTR_ERR(sa1100_rtc->rtc);
336+
333337
pxa_rtc->base = devm_ioremap(dev, pxa_rtc->ress->start,
334338
resource_size(pxa_rtc->ress));
335339
if (!pxa_rtc->base) {

0 commit comments

Comments
 (0)