mwifiex: clean up scan state on error
authorBing Zhao <bzhao@marvell.com>
Sat, 20 Oct 2012 02:02:00 +0000 (19:02 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 24 Oct 2012 17:18:09 +0000 (13:18 -0400)
De-reference and deallocate scan state on failure.

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
Reviewed-by: Ryan Cairns <rtc@chromium.org>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mwifiex/cfg80211.c

index 0679458a1bac44469ddf0d00935e7b165f66f9ed..780d3e168297fcf80c62e4345ac6d29c22007b73 100644 (file)
@@ -1825,8 +1825,6 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy,
                return -EBUSY;
        }
 
-       priv->scan_request = request;
-
        priv->user_scan_cfg = kzalloc(sizeof(struct mwifiex_user_scan_cfg),
                                      GFP_KERNEL);
        if (!priv->user_scan_cfg) {
@@ -1834,6 +1832,8 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy,
                return -ENOMEM;
        }
 
+       priv->scan_request = request;
+
        priv->user_scan_cfg->num_ssids = request->n_ssids;
        priv->user_scan_cfg->ssid_list = request->ssids;
 
@@ -1870,6 +1870,9 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy,
        ret = mwifiex_scan_networks(priv, priv->user_scan_cfg);
        if (ret) {
                dev_err(priv->adapter->dev, "scan failed: %d\n", ret);
+               priv->scan_request = NULL;
+               kfree(priv->user_scan_cfg);
+               priv->user_scan_cfg = NULL;
                return ret;
        }