Message ID | 200909211553.38409.herton@mandriva.com.br |
---|---|
State | Superseded, archived |
Headers | show |
On Mon, 21 Sep 2009 15:53:38 -0300 Herton Ronaldo Krzesinski <herton@mandriva.com.br> wrote: > The problem here is the rtc char device being created early and acessible before > rtc_cmos does dev_set_drvdata(dev, &cmos_rtc), so dev_get_drvdata in > cmos_rtc_ioctl can return null, like in this example where hwclock is run right > after char device creation that triggers the udev rule: > ACTION=="add", SUBSYSTEM=="rtc", RUN+="/sbin/hwclock --hctosys --rtc=/dev/%k" > And makes the oops possible, in this case hwclock looks to open and close the > device fast enough. right. the best option would be to use the new irq api that was introduced after the creation of rtc_cmos (and thus remove the whole ioctl routine). [...] > But I saw another issue: looks it could be possible that as cmos_rtc_ioctl > (ioctl) can be run before rtc_device_register returns, the following call chain > could happen in current code: > cmos_rtc_ioctl->cmos_irq_{en,dis}able->cmos_checkintr->rtc_update_irq > rtc_update_irq uses cmos->rtc, which is set only at return of > rtc_device_register, and here we may have another problem... is it > possible? this shouldn't happen, irqs are enabled only after everything has been setup to handle them.
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index f7a4701..071f9ed 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c @@ -723,6 +723,8 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) } } + dev_set_drvdata(dev, &cmos_rtc); + cmos_rtc.rtc = rtc_device_register(driver_name, dev, &cmos_rtc_ops, THIS_MODULE); if (IS_ERR(cmos_rtc.rtc)) { @@ -731,7 +733,6 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq) } cmos_rtc.dev = dev; - dev_set_drvdata(dev, &cmos_rtc); rename_region(ports, dev_name(&cmos_rtc.rtc->dev)); spin_lock_irq(&rtc_lock);