cfg80211: fix possible memory leak in cfg80211_iter_combinations()
authorWei Yongjun <weiyongjun1@huawei.com>
Mon, 17 Oct 2016 15:25:16 +0000 (15:25 +0000)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 18 Oct 2016 06:52:00 +0000 (08:52 +0200)
'limits' is malloced in cfg80211_iter_combinations() and should be freed
before leaving from the error handling cases, otherwise it will cause
memory leak.

Fixes: 0c317a02ca98 ("cfg80211: support virtual interfaces with different beacon intervals")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/util.c

index d2ea1f1..ec17c28 100644 (file)
@@ -1676,8 +1676,10 @@ int cfg80211_iter_combinations(struct wiphy *wiphy,
 
                if (params->beacon_int_gcd) {
                        if (c->beacon_int_min_gcd &&
-                           params->beacon_int_gcd < c->beacon_int_min_gcd)
+                           params->beacon_int_gcd < c->beacon_int_min_gcd) {
+                               kfree(limits);
                                return -EINVAL;
+                       }
                        if (!c->beacon_int_min_gcd &&
                            params->beacon_int_different)
                                goto cont;