Commit d165e4ef authored by Jes Sorensen's avatar Jes Sorensen Committed by Greg Kroah-Hartman

staging: rtl8723au: rtw_wdev_alloc(): Don't register wiphy before kmalloc() completed

There is no point starting to register the wiphy and then having to
unregister it again if the followon kmalloc() fails.
Signed-off-by: default avatarJes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 56b0bd91
...@@ -3367,22 +3367,24 @@ int rtw_wdev_alloc(struct rtw_adapter *padapter, struct device *dev) ...@@ -3367,22 +3367,24 @@ int rtw_wdev_alloc(struct rtw_adapter *padapter, struct device *dev)
ret = -ENOMEM; ret = -ENOMEM;
goto exit; goto exit;
} }
/* wdev */
wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
if (!wdev) {
DBG_8723A("Couldn't allocate wireless device\n");
ret = -ENOMEM;
goto free_wiphy;
}
set_wiphy_dev(wiphy, dev); set_wiphy_dev(wiphy, dev);
rtw_cfg80211_preinit_wiphy(padapter, wiphy); rtw_cfg80211_preinit_wiphy(padapter, wiphy);
ret = wiphy_register(wiphy); ret = wiphy_register(wiphy);
if (ret < 0) { if (ret < 0) {
DBG_8723A("Couldn't register wiphy device\n"); DBG_8723A("Couldn't register wiphy device\n");
goto free_wiphy; goto free_wdev;
} }
/* wdev */
wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
if (!wdev) {
DBG_8723A("Couldn't allocate wireless device\n");
ret = -ENOMEM;
goto unregister_wiphy;
}
wdev->wiphy = wiphy; wdev->wiphy = wiphy;
wdev->netdev = pnetdev; wdev->netdev = pnetdev;
/* wdev->iftype = NL80211_IFTYPE_STATION; */ /* wdev->iftype = NL80211_IFTYPE_STATION; */
...@@ -3408,8 +3410,8 @@ int rtw_wdev_alloc(struct rtw_adapter *padapter, struct device *dev) ...@@ -3408,8 +3410,8 @@ int rtw_wdev_alloc(struct rtw_adapter *padapter, struct device *dev)
pwdev_priv->power_mgmt = false; pwdev_priv->power_mgmt = false;
return ret; return ret;
unregister_wiphy: free_wdev:
wiphy_unregister(wiphy); kfree(wdev);
free_wiphy: free_wiphy:
wiphy_free(wiphy); wiphy_free(wiphy);
exit: exit:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment