net: wireless: bcmdhd: Fix possible memory leak in escan/iscan
authorDmitry Shmidt <dimitrysh@google.com>
Fri, 4 Nov 2011 20:56:28 +0000 (13:56 -0700)
committerDmitry Shmidt <dimitrysh@google.com>
Sat, 12 Nov 2011 00:14:07 +0000 (16:14 -0800)
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
drivers/net/wireless/bcmdhd/wl_cfg80211.c

index 526ba47895bc29c7b14c678332cae72276ca6d76..daa7d2605aafccbd048dafd7b75ff06cd9fab8f7 100644 (file)
@@ -1245,8 +1245,7 @@ wl_run_iscan(struct wl_iscan_ctrl *iscan, struct cfg80211_scan_request *request,
        }
        params = (struct wl_iscan_params *)kzalloc(params_size, GFP_KERNEL);
        if (!params) {
-               err = -ENOMEM;
-               goto done;
+               return -ENOMEM;
        }
 
        if (request != NULL)
@@ -1270,8 +1269,8 @@ wl_run_iscan(struct wl_iscan_ctrl *iscan, struct cfg80211_scan_request *request,
                        WL_ERR(("error (%d)\n", err));
                }
        }
-       kfree(params);
 done:
+       kfree(params);
        return err;
 }
 
@@ -1348,6 +1347,7 @@ wl_run_escan(struct wl_priv *wl, struct net_device *ndev,
                params->sync_id = htod16(0x1234);
                if (params_size + sizeof("escan") >= WLC_IOCTL_MEDLEN) {
                        WL_ERR(("ioctl buffer length not sufficient\n"));
+                       kfree(params);
                        err = -ENOMEM;
                        goto exit;
                }