diff options
author | David Brownell <david-b@pacbell.net> | 2007-03-01 05:12:40 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-03-01 23:53:37 +0100 |
commit | e109ebd1eed2b91e3c9bb3b42cc27961f0dc22b3 (patch) | |
tree | 402ca61d265c59d35282b0786363dfbe32659564 /drivers/rtc/class.c | |
parent | [PATCH] MAINTAINERS: Update email address (diff) | |
download | linux-e109ebd1eed2b91e3c9bb3b42cc27961f0dc22b3.tar.xz linux-e109ebd1eed2b91e3c9bb3b42cc27961f0dc22b3.zip |
[PATCH] rtc_cmos oops fix
Fix an oops on the rtc_device_unregister() path by waiting until the last
moment before nulling the rtc->ops vector. Fix some potential oopses by
having the rtc_class_open()/rtc_class_close() interface increase the RTC's
reference count while an RTC handle is available outside the RTC framework.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/class.c')
-rw-r--r-- | drivers/rtc/class.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 7a0d8ee2de9c..04aaa6347234 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -113,10 +113,16 @@ EXPORT_SYMBOL_GPL(rtc_device_register); */ void rtc_device_unregister(struct rtc_device *rtc) { - mutex_lock(&rtc->ops_lock); - rtc->ops = NULL; - mutex_unlock(&rtc->ops_lock); - class_device_unregister(&rtc->class_dev); + if (class_device_get(&rtc->class_dev) != NULL) { + mutex_lock(&rtc->ops_lock); + /* remove innards of this RTC, then disable it, before + * letting any rtc_class_open() users access it again + */ + class_device_unregister(&rtc->class_dev); + rtc->ops = NULL; + mutex_unlock(&rtc->ops_lock); + class_device_put(&rtc->class_dev); + } } EXPORT_SYMBOL_GPL(rtc_device_unregister); |