From: Greg KH on
2.6.32-stable review patch. If anyone has any objections, please let us know.


From: Dan Carpenter <error27(a)>

commit 6ba8bcd457d9fc793ac9435aa2e4138f571d4ec5 upstream.

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: Randy Dunlap <randy.dunlap(a)>
Signed-off-by: Dan Carpenter <error27(a)>
Tested-by: Randy Dunlap <randy.dunlap(a)>
Cc: Alessandro Zummo <a.zummo(a)>
Cc: Paul Gortmaker <p_gortmaker(a)>
Cc: Malte Schroder <maltesch(a)>
Cc: Ralf Baechle <ralf(a)>
Cc: Herton Ronaldo Krzesinski <herton(a)>
Signed-off-by: Andrew Morton <akpm(a)>
Signed-off-by: Linus Torvalds <torvalds(a)>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)>

drivers/rtc/rtc-cmos.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -723,6 +723,9 @@ cmos_do_probe(struct device *dev, struct

+ = 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)) {
@@ -730,8 +733,6 @@ cmos_do_probe(struct device *dev, struct
goto cleanup0;

- = dev;
- dev_set_drvdata(dev, &cmos_rtc);
rename_region(ports, dev_name(&cmos_rtc.rtc->dev));


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)
More majordomo info at
Please read the FAQ at