Hi, Aisheng

> > From: anson.hu...@nxp.com <anson.hu...@nxp.com>
> > Sent: Tuesday, July 16, 2019 3:19 PM
> >
> > The RTC IRQ is requested before the struct rtc_device is allocated,
> > this may lead to a NULL pointer dereference in 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.
> >
> 
> I saw other rtc drivers did the same way as us, so this looks like a common
> problem.
> My question is if we can clear interrupt status before register to avoid this
> issue as other rtc drivers?

I think we can NOT predict when the IRQ will be pending, IRQ could arrive at 
any time,
the most safe way is to prepare everything before requesting/enabling IRQ.
There is also patch to fix similar issue:

commit 060711f5274dfc2d76a5b2cd65abf6ccbf061e40
Author: Alexandre Belloni <alexandre.bell...@bootlin.com>
Date:   Tue Apr 30 11:32:09 2019 +0200

    rtc: digicolor: fix possible race condition

Anson 

Reply via email to