staging: rtl8723au: rtw_wdev_alloc(): Don't register wiphy before kmalloc() completed
authorJes Sorensen <Jes.Sorensen@redhat.com>
Sun, 25 May 2014 20:43:18 +0000 (22:43 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 May 2014 22:14:40 +0000 (15:14 -0700)
There is no point starting to register the wiphy and then having to
unregister it again if the followon kmalloc() fails.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c

index 9f9f034fd5e6cc96feb97b8a7a5c69555c06e304..4528c95b8e6713d65e73d6db45a7fd64fcd7d7f2 100644 (file)
@@ -3367,22 +3367,24 @@ int rtw_wdev_alloc(struct rtw_adapter *padapter, struct device *dev)
                ret = -ENOMEM;
                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);
        rtw_cfg80211_preinit_wiphy(padapter, wiphy);
 
        ret = wiphy_register(wiphy);
        if (ret < 0) {
                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->netdev = pnetdev;
        /* wdev->iftype = NL80211_IFTYPE_STATION; */
@@ -3408,8 +3410,8 @@ int rtw_wdev_alloc(struct rtw_adapter *padapter, struct device *dev)
                pwdev_priv->power_mgmt = false;
 
        return ret;
-unregister_wiphy:
-       wiphy_unregister(wiphy);
+free_wdev:
+       kfree(wdev);
 free_wiphy:
        wiphy_free(wiphy);
 exit: