Commit 6ba8bcd4 authored by Dan Carpenter's avatar Dan Carpenter Committed by Linus Torvalds
Browse files

rtc-cmos: do dev_set_drvdata() earlier in the initialization

The bug is an oops when dev_get_drvdata() returned null in
cmos_update_irq_enable().  The call tree looks like this:
    => rtc_update_irq_enable()
      => cmos_update_irq_enable()

It's caused by a race condition in the module initialization.  It is
rtc_device_register() which makes the ioctl operations live so I moved
the call to dev_set_drvdata() before the call to rtc_device_register().


Reported-by: default avatarRandy Dunlap <>
Signed-off-by: default avatarDan Carpenter <>
Tested-by: default avatarRandy Dunlap <>
Cc: Alessandro Zummo <>
Cc: Paul Gortmaker <>
Cc: Malte Schroder <>
Cc: Ralf Baechle <>
Cc: Herton Ronaldo Krzesinski <>
Cc: <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 72cc8e51
......@@ -719,6 +719,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
} = dev;
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)) {
......@@ -726,8 +729,6 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
goto cleanup0;
} = dev;
dev_set_drvdata(dev, &cmos_rtc);
rename_region(ports, dev_name(&cmos_rtc.rtc->dev));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment