Re: [PATCH] cfg80211: fix potential deadlock regression
From: Maxime Bizon <hidden>
Date: 2013-08-28 19:58:45
On Tue, 2013-06-04 at 22:22 +0200, Johannes Berg wrote:
- rtnl_lock(); res = device_add(&rdev->wiphy.dev); + if (res) + return res;
I just ran across a regression caused by this commit
I'm again getting uevent notifications for wireless devices that are not
yet properly registered (ENODEV on NL80211 when using sysfs phy id)
I originally fixed the bug by taking the cfg80211 mutex across the
whole registration:
commit 5a652052fedbd7869572c757dd2ffc2ed420c69d
Author: Maxime Bizon [off-list ref]
Date: Wed Jul 21 17:21:38 2010 +0200
cfg80211: fix race between sysfs and cfg80211
device_add() is called before adding the phy to the cfg80211 device
list.
So if a userspace program uses sysfs uevents to detect new phy
devices, and queries nl80211 to get phy info, it can get ENODEV even
though the phy exists in sysfs.
An easy workaround is to hold the cfg80211 mutex until the phy is
present in sysfs/cfg80211/debugfs.
It does not seem we can reverse the rfkill_register() and device_add()
because wiphy dev is a parent of rfkill dev.
any idea to fix this ?
Thanks,
--
Maxime