summaryrefslogtreecommitdiffstats
path: root/net/wireless/wext-compat.c
diff options
context:
space:
mode:
authorStefan Seyfried <seife+kernel@b1-systems.com>2018-09-30 06:53:00 -0400
committerJohannes Berg <johannes.berg@intel.com>2018-10-01 03:11:36 -0400
commit848e616e66d4592fe9afc40743d3504deb7632b4 (patch)
treefe248e4b36418a1c2a168ff01c0738fcbcf97d52 /net/wireless/wext-compat.c
parent43955a45dc0b4f3be7f0c3afc0e080ed59bb5280 (diff)
cfg80211: fix wext-compat memory leak
cfg80211_wext_giwrate and sinfo.pertid might allocate sinfo.pertid via rdev_get_station(), but never release it. Fix that. Fixes: 8689c051a201 ("cfg80211: dynamically allocate per-tid stats for station info") Signed-off-by: Stefan Seyfried <seife+kernel@b1-systems.com> [johannes: fix error path, use cfg80211_sinfo_release_content(), add Fixes] Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/wext-compat.c')
-rw-r--r--net/wireless/wext-compat.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index 167f7025ac98..06943d9c9835 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -1278,12 +1278,16 @@ static int cfg80211_wext_giwrate(struct net_device *dev,
1278 if (err) 1278 if (err)
1279 return err; 1279 return err;
1280 1280
1281 if (!(sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE))) 1281 if (!(sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE))) {
1282 return -EOPNOTSUPP; 1282 err = -EOPNOTSUPP;
1283 goto free;
1284 }
1283 1285
1284 rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate); 1286 rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate);
1285 1287
1286 return 0; 1288free:
1289 cfg80211_sinfo_release_content(&sinfo);
1290 return err;
1287} 1291}
1288 1292
1289/* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */ 1293/* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */
@@ -1293,7 +1297,7 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
1293 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); 1297 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1294 /* we are under RTNL - globally locked - so can use static structs */ 1298 /* we are under RTNL - globally locked - so can use static structs */
1295 static struct iw_statistics wstats; 1299 static struct iw_statistics wstats;
1296 static struct station_info sinfo; 1300 static struct station_info sinfo = {};
1297 u8 bssid[ETH_ALEN]; 1301 u8 bssid[ETH_ALEN];
1298 1302
1299 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION) 1303 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION)
@@ -1352,6 +1356,8 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
1352 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_FAILED)) 1356 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_FAILED))
1353 wstats.discard.retries = sinfo.tx_failed; 1357 wstats.discard.retries = sinfo.tx_failed;
1354 1358
1359 cfg80211_sinfo_release_content(&sinfo);
1360
1355 return &wstats; 1361 return &wstats;
1356} 1362}
1357 1363