summaryrefslogtreecommitdiff
path: root/drivers/rtc
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>2017-10-13 00:04:47 +0200
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>2017-10-13 00:10:12 +0200
commit9da32ba64d59d577297bf766a3f12753ebef5712 (patch)
treeb3d8ba4e5f3f1bf14edb2f06be2b01d47e4248c9 /drivers/rtc
parent9360a6a81862d3acfeb44745d9db4f9861ba4159 (diff)
rtc: abx80x: solve race condition
There is a race condition that can happen if abx80x_probe() fails after the rtc registration succeeded. Solve that by moving the registration at the end of the probe function. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-abx80x.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
index 442e62a3c9a9..b033bc556f5d 100644
--- a/drivers/rtc/rtc-abx80x.c
+++ b/drivers/rtc/rtc-abx80x.c
@@ -620,10 +620,6 @@ static int abx80x_probe(struct i2c_client *client,
rtc->ops = &abx80x_rtc_ops;
- err = rtc_register_device(rtc);
- if (err)
- return err;
-
i2c_set_clientdata(client, rtc);
if (client->irq > 0) {
@@ -650,10 +646,14 @@ static int abx80x_probe(struct i2c_client *client,
err = devm_add_action_or_reset(&client->dev,
rtc_calib_remove_sysfs_group,
&client->dev);
- if (err)
+ if (err) {
dev_err(&client->dev,
"Failed to add sysfs cleanup action: %d\n",
err);
+ return err;
+ }
+
+ err = rtc_register_device(rtc);
return err;
}