Patchwork [2/2] rtc: ep93xx: fix crash on boot

login
register
mail settings
Submitter Wolfram Sang
Date May 5, 2011, 9:46 a.m.
Message ID <1304588775-30408-2-git-send-email-w.sang@pengutronix.de>
Download mbox | patch
Permalink /patch/94215/
State New
Headers show

Comments

Wolfram Sang - May 5, 2011, 9:46 a.m.
Commit f44f7f96a20 ("RTC: Initialize kernel state from RTC") caused a
crash when initializing the driver.

The reason is that rtc_device_register() calls rtc_read_alarm() after
that change, when the driver does not have all driver data set up yet.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: john stultz <johnstul@us.ibm.com>
---
 drivers/rtc/rtc-ep93xx.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
john stultz - May 5, 2011, 6:54 p.m.
On Thu, 2011-05-05 at 11:46 +0200, Wolfram Sang wrote:
> Commit f44f7f96a20 ("RTC: Initialize kernel state from RTC") caused a
> crash when initializing the driver.
> 
> The reason is that rtc_device_register() calls rtc_read_alarm() after
> that change, when the driver does not have all driver data set up yet.
> 
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> Cc: john stultz <johnstul@us.ibm.com>

Acked-by: John Stultz <johnstul@us.ibm.com>

Patch

diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c
index 11ae64d..335551d 100644
--- a/drivers/rtc/rtc-ep93xx.c
+++ b/drivers/rtc/rtc-ep93xx.c
@@ -151,6 +151,7 @@  static int __init ep93xx_rtc_probe(struct platform_device *pdev)
 		return -ENXIO;
 
 	pdev->dev.platform_data = ep93xx_rtc;
+	platform_set_drvdata(pdev, rtc);
 
 	rtc = rtc_device_register(pdev->name,
 				&pdev->dev, &ep93xx_rtc_ops, THIS_MODULE);
@@ -159,8 +160,6 @@  static int __init ep93xx_rtc_probe(struct platform_device *pdev)
 		goto exit;
 	}
 
-	platform_set_drvdata(pdev, rtc);
-
 	err = sysfs_create_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files);
 	if (err)
 		goto fail;
@@ -168,9 +167,9 @@  static int __init ep93xx_rtc_probe(struct platform_device *pdev)
 	return 0;
 
 fail:
-	platform_set_drvdata(pdev, NULL);
 	rtc_device_unregister(rtc);
 exit:
+	platform_set_drvdata(pdev, NULL);
 	pdev->dev.platform_data = NULL;
 	return err;
 }