From 1eca4865446edf2e2eec5300f105827815088790 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Tue, 29 Nov 2022 16:41:04 +0000 Subject: [PATCH] rtl8723ds: fix locking for (un)register rtnl_is_locked() checks whether the lock is currently held by any task, not specifically by _this_ task so it is wrong to use it in the (un)register path. In both of these cases, examining the call stack shows that there is no way for rtnl_lock to be taken by the task running these functions, so remove the checks. Further, (un)register_netdev() have existed since the beginning of Git history so there's no reason for a version check here and we can always call the function that takes the lock itself and should never call the version which expects rtnl_lock to be held. --- os_dep/linux/os_intfs.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index d513934..76510e9 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -1402,13 +1402,7 @@ int rtw_os_ndev_register(_adapter *adapter, const char *name) /* Tell the network stack we exist */ - #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)) - if (!rtnl_is_locked()) - ret = (register_netdev(ndev) == 0) ? _SUCCESS : _FAIL; - else - #endif - ret = (register_netdevice(ndev) == 0) ? _SUCCESS : _FAIL; - + ret = (register_netdev(ndev) == 0) ? _SUCCESS : _FAIL; if (ret == _SUCCESS) adapter->registered = 1; else @@ -1447,14 +1441,8 @@ void rtw_os_ndev_unregister(_adapter *adapter) rtw_cfg80211_ndev_res_unregister(adapter); #endif - if ((adapter->DriverState != DRIVER_DISAPPEAR) && netdev) { - #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)) - if (!rtnl_is_locked()) - unregister_netdev(netdev); - else - #endif - unregister_netdevice(netdev); - } + if ((adapter->DriverState != DRIVER_DISAPPEAR) && netdev) + unregister_netdev(netdev); #if defined(CONFIG_IOCTL_CFG80211) && !defined(RTW_SINGLE_WIPHY) rtw_wiphy_unregister(adapter_to_wiphy(adapter));