Re: kernfs/rtc: circular dependency between kernfs and ops_lock

From: Alessandro Zummo
Date: Tue Mar 25 2014 - 18:39:48 EST


On Tue, 25 Mar 2014 17:52:30 -0400
Sasha Levin <sasha.levin@xxxxxxxxxx> wrote:

> >
> > Pretty interesting indeed. One option would be to remove
> > the sys files before acquiring the lock. But I wonder
> > if this could lead to other issues.
> >
>
> Ping? Seems this thing got lost.

What if we move

rtc_sysfs_del_device(rtc);

before acquiring the lock?

diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index 589351e..a0c19a3 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -261,11 +261,13 @@ EXPORT_SYMBOL_GPL(rtc_device_register);
void rtc_device_unregister(struct rtc_device *rtc)
{
if (get_device(&rtc->dev) != NULL) {
+
+ rtc_sysfs_del_device(rtc);
+
mutex_lock(&rtc->ops_lock);
/* remove innards of this RTC, then disable it, before
* letting any rtc_class_open() users access it again
*/
- rtc_sysfs_del_device(rtc);
rtc_dev_del_device(rtc);
rtc_proc_del_device(rtc);
device_unregister(&rtc->dev);


--

Best regards,

Alessandro Zummo,
Tower Technologies - Torino, Italy

http://www.towertech.it

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/