aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>2017-10-12 18:04:47 -0400
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>2017-10-12 18:10:12 -0400
commit9da32ba64d59d577297bf766a3f12753ebef5712 (patch)
treeb3d8ba4e5f3f1bf14edb2f06be2b01d47e4248c9
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>
-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,
620 620
621 rtc->ops = &abx80x_rtc_ops; 621 rtc->ops = &abx80x_rtc_ops;
622 622
623 err = rtc_register_device(rtc);
624 if (err)
625 return err;
626
627 i2c_set_clientdata(client, rtc); 623 i2c_set_clientdata(client, rtc);
628 624
629 if (client->irq > 0) { 625 if (client->irq > 0) {
@@ -650,10 +646,14 @@ static int abx80x_probe(struct i2c_client *client,
650 err = devm_add_action_or_reset(&client->dev, 646 err = devm_add_action_or_reset(&client->dev,
651 rtc_calib_remove_sysfs_group, 647 rtc_calib_remove_sysfs_group,
652 &client->dev); 648 &client->dev);
653 if (err) 649 if (err) {
654 dev_err(&client->dev, 650 dev_err(&client->dev,
655 "Failed to add sysfs cleanup action: %d\n", 651 "Failed to add sysfs cleanup action: %d\n",
656 err); 652 err);
653 return err;
654 }
655
656 err = rtc_register_device(rtc);
657 657
658 return err; 658 return err;
659} 659}