[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>
This commit is contained in:
parent
0478e62e8a
commit
e109ebd1ee
@ -113,10 +113,16 @@ EXPORT_SYMBOL_GPL(rtc_device_register);
|
|||||||
*/
|
*/
|
||||||
void rtc_device_unregister(struct rtc_device *rtc)
|
void rtc_device_unregister(struct rtc_device *rtc)
|
||||||
{
|
{
|
||||||
mutex_lock(&rtc->ops_lock);
|
if (class_device_get(&rtc->class_dev) != NULL) {
|
||||||
rtc->ops = NULL;
|
mutex_lock(&rtc->ops_lock);
|
||||||
mutex_unlock(&rtc->ops_lock);
|
/* remove innards of this RTC, then disable it, before
|
||||||
class_device_unregister(&rtc->class_dev);
|
* 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);
|
EXPORT_SYMBOL_GPL(rtc_device_unregister);
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ struct class_device *rtc_class_open(char *name)
|
|||||||
down(&rtc_class->sem);
|
down(&rtc_class->sem);
|
||||||
list_for_each_entry(class_dev_tmp, &rtc_class->children, node) {
|
list_for_each_entry(class_dev_tmp, &rtc_class->children, node) {
|
||||||
if (strncmp(class_dev_tmp->class_id, name, BUS_ID_SIZE) == 0) {
|
if (strncmp(class_dev_tmp->class_id, name, BUS_ID_SIZE) == 0) {
|
||||||
class_dev = class_dev_tmp;
|
class_dev = class_device_get(class_dev_tmp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,6 +197,7 @@ EXPORT_SYMBOL_GPL(rtc_class_open);
|
|||||||
void rtc_class_close(struct class_device *class_dev)
|
void rtc_class_close(struct class_device *class_dev)
|
||||||
{
|
{
|
||||||
module_put(to_rtc_device(class_dev)->owner);
|
module_put(to_rtc_device(class_dev)->owner);
|
||||||
|
class_device_put(class_dev);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(rtc_class_close);
|
EXPORT_SYMBOL_GPL(rtc_class_close);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user