Commit 9da32ba6 authored by Alexandre Belloni's avatar Alexandre Belloni

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: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
parent 9360a6a8
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment