[44/45] rtc: tx4939: fix possible race condition

Message ID 20180212224759.15999-45-alexandre.belloni@bootlin.com
State Accepted
Headers show
Series
  • RTC: nvmem improvements
Related show

Commit Message

Alexandre Belloni Feb. 12, 2018, 10:47 p.m.
The probe function is not allowed to fail after registering the RTC. Call
rtc_register_device() at the end.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-tx4939.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch

diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c
index 75c3887fbc6c..5a3a6b457b8f 100644
--- a/drivers/rtc/rtc-tx4939.c
+++ b/drivers/rtc/rtc-tx4939.c
@@ -289,12 +289,13 @@  static int __init tx4939_rtc_probe(struct platform_device *pdev)
 
 	rtc->ops = &tx4939_rtc_ops;
 
-	ret = rtc_register_device(rtc);
+	ret = sysfs_create_bin_file(&pdev->dev.kobj, &tx4939_rtc_nvram_attr);
 	if (ret)
 		return ret;
 
 	pdata->rtc = rtc;
-	ret = sysfs_create_bin_file(&pdev->dev.kobj, &tx4939_rtc_nvram_attr);
+
+	ret = rtc_register_device(rtc);
 
 	return ret;
 }