diff options
author | Alessandro Zummo <a.zummo@towertech.it> | 2014-04-03 17:49:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-03 19:21:16 -0400 |
commit | 4071ea25cc08d41002746cca2d69ac700d67a2ac (patch) | |
tree | 43cf44f8265b885c8c1e4e81f0ced5c6babb53c7 /drivers/rtc/rtc-ds1511.c | |
parent | a68b31080912dae377bee4994716b357dc74286d (diff) |
rtc: fix potential race condition
RTC drivers must not return an error after device registration.
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Reported-by: Ales Novak <alnovak@suse.cz>
Cc: Alexander Shiyan <shc_work@mail.ru>
Cc: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-ds1511.c')
-rw-r--r-- | drivers/rtc/rtc-ds1511.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c index bc7b4fcf603c..4ff20f9dc212 100644 --- a/drivers/rtc/rtc-ds1511.c +++ b/drivers/rtc/rtc-ds1511.c | |||
@@ -473,7 +473,6 @@ static struct bin_attribute ds1511_nvram_attr = { | |||
473 | 473 | ||
474 | static int ds1511_rtc_probe(struct platform_device *pdev) | 474 | static int ds1511_rtc_probe(struct platform_device *pdev) |
475 | { | 475 | { |
476 | struct rtc_device *rtc; | ||
477 | struct resource *res; | 476 | struct resource *res; |
478 | struct rtc_plat_data *pdata; | 477 | struct rtc_plat_data *pdata; |
479 | int ret = 0; | 478 | int ret = 0; |
@@ -512,6 +511,12 @@ static int ds1511_rtc_probe(struct platform_device *pdev) | |||
512 | 511 | ||
513 | spin_lock_init(&pdata->lock); | 512 | spin_lock_init(&pdata->lock); |
514 | platform_set_drvdata(pdev, pdata); | 513 | platform_set_drvdata(pdev, pdata); |
514 | |||
515 | pdata->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, | ||
516 | &ds1511_rtc_ops, THIS_MODULE); | ||
517 | if (IS_ERR(pdata->rtc)) | ||
518 | return PTR_ERR(pdata->rtc); | ||
519 | |||
515 | /* | 520 | /* |
516 | * if the platform has an interrupt in mind for this device, | 521 | * if the platform has an interrupt in mind for this device, |
517 | * then by all means, set it | 522 | * then by all means, set it |
@@ -526,15 +531,12 @@ static int ds1511_rtc_probe(struct platform_device *pdev) | |||
526 | } | 531 | } |
527 | } | 532 | } |
528 | 533 | ||
529 | rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &ds1511_rtc_ops, | ||
530 | THIS_MODULE); | ||
531 | if (IS_ERR(rtc)) | ||
532 | return PTR_ERR(rtc); | ||
533 | pdata->rtc = rtc; | ||
534 | |||
535 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1511_nvram_attr); | 534 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1511_nvram_attr); |
535 | if (ret) | ||
536 | dev_err(&pdev->dev, "Unable to create sysfs entry: %s\n", | ||
537 | ds1511_nvram_attr.attr.name); | ||
536 | 538 | ||
537 | return ret; | 539 | return 0; |
538 | } | 540 | } |
539 | 541 | ||
540 | static int ds1511_rtc_remove(struct platform_device *pdev) | 542 | static int ds1511_rtc_remove(struct platform_device *pdev) |