fix netdev (un)registration deadlock

This commit is contained in:
Alex Shumsky 2024-06-07 23:47:17 +03:00
parent 358f13d174
commit 14a60a7399
2 changed files with 16 additions and 0 deletions

View File

@ -5060,7 +5060,11 @@ static int rtw_cfg80211_add_monitor_if(_adapter *padapter, char *name, struct ne
mon_wdev->iftype = NL80211_IFTYPE_MONITOR; mon_wdev->iftype = NL80211_IFTYPE_MONITOR;
mon_ndev->ieee80211_ptr = mon_wdev; mon_ndev->ieee80211_ptr = mon_wdev;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
ret = cfg80211_register_netdevice(mon_ndev);
#else
ret = register_netdevice(mon_ndev); ret = register_netdevice(mon_ndev);
#endif
if (ret) if (ret)
goto out; goto out;
@ -6762,7 +6766,11 @@ static int cfg80211_rtw_del_virtual_intf(struct wiphy *wiphy,
pwdev_priv = adapter_wdev_data(adapter); pwdev_priv = adapter_wdev_data(adapter);
if (ndev == pwdev_priv->pmon_ndev) { if (ndev == pwdev_priv->pmon_ndev) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
cfg80211_unregister_netdevice(ndev);
#else
unregister_netdevice(ndev); unregister_netdevice(ndev);
#endif
pwdev_priv->pmon_ndev = NULL; pwdev_priv->pmon_ndev = NULL;
pwdev_priv->ifname_mon[0] = '\0'; pwdev_priv->ifname_mon[0] = '\0';
RTW_INFO(FUNC_NDEV_FMT" remove monitor ndev\n", FUNC_NDEV_ARG(ndev)); RTW_INFO(FUNC_NDEV_FMT" remove monitor ndev\n", FUNC_NDEV_ARG(ndev));

View File

@ -2192,7 +2192,11 @@ int rtw_os_ndev_register(_adapter *adapter, const char *name)
if (rtnl_lock_needed) if (rtnl_lock_needed)
ret = (register_netdev(ndev) == 0) ? _SUCCESS : _FAIL; ret = (register_netdev(ndev) == 0) ? _SUCCESS : _FAIL;
else else
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
ret = (cfg80211_register_netdevice(ndev) == 0) ? _SUCCESS : _FAIL;
#else
ret = (register_netdevice(ndev) == 0) ? _SUCCESS : _FAIL; ret = (register_netdevice(ndev) == 0) ? _SUCCESS : _FAIL;
#endif
if (ret == _SUCCESS) if (ret == _SUCCESS)
adapter->registered = 1; adapter->registered = 1;
@ -2241,7 +2245,11 @@ void rtw_os_ndev_unregister(_adapter *adapter)
if (rtnl_lock_needed) if (rtnl_lock_needed)
unregister_netdev(netdev); unregister_netdev(netdev);
else else
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
cfg80211_unregister_netdevice(netdev);
#else
unregister_netdevice(netdev); unregister_netdevice(netdev);
#endif
} }
#if defined(CONFIG_IOCTL_CFG80211) && !defined(RTW_SINGLE_WIPHY) #if defined(CONFIG_IOCTL_CFG80211) && !defined(RTW_SINGLE_WIPHY)