Patchwork rtc: rv3029c2: Fix potential race condition

login
register
mail settings
Submitter Gregory Hermant
Date March 24, 2014, 8:26 a.m.
Message ID <1395649598-4931-1-git-send-email-gregory.hermant@calao-systems.com>
Download mbox | patch
Permalink /patch/332980/
State New
Headers show

Comments

Gregory Hermant - March 24, 2014, 8:26 a.m.
RTC drivers must not return an error after
device registration.

Acked-by: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Gregory Hermant <gregory.hermant@calao-systems.com>
---
 drivers/rtc/rtc-rv3029c2.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Patch

diff --git a/drivers/rtc/rtc-rv3029c2.c b/drivers/rtc/rtc-rv3029c2.c
index 1a779a6..e9ac5a4 100644
--- a/drivers/rtc/rtc-rv3029c2.c
+++ b/drivers/rtc/rtc-rv3029c2.c
@@ -395,6 +395,12 @@  static int rv3029c2_probe(struct i2c_client *client,
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_EMUL))
 		return -ENODEV;
 
+	rc = rv3029c2_i2c_get_sr(client, buf);
+	if (rc < 0) {
+		dev_err(&client->dev, "reading status failed\n");
+		return rc;
+	}
+
 	rtc = devm_rtc_device_register(&client->dev, client->name,
 					&rv3029c2_rtc_ops, THIS_MODULE);
 
@@ -403,12 +409,6 @@  static int rv3029c2_probe(struct i2c_client *client,
 
 	i2c_set_clientdata(client, rtc);
 
-	rc = rv3029c2_i2c_get_sr(client, buf);
-	if (rc < 0) {
-		dev_err(&client->dev, "reading status failed\n");
-		return rc;
-	}
-
 	return 0;
 }