Skip to content

Commit 50b2e87

Browse files
zt19901990jmberg-intel
authored andcommitted
wifi: mac80211: fix memory free error when registering wiphy fail
ieee80211_register_hw free the allocated cipher suites when registering wiphy fail, and ieee80211_free_hw will re-free it. set wiphy_ciphers_allocated to false after freeing allocated cipher suites. Signed-off-by: taozhang <taozhang@bestechnic.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 03c0ad4 commit 50b2e87

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

net/mac80211/main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,8 +1439,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
14391439
ieee80211_led_exit(local);
14401440
destroy_workqueue(local->workqueue);
14411441
fail_workqueue:
1442-
if (local->wiphy_ciphers_allocated)
1442+
if (local->wiphy_ciphers_allocated) {
14431443
kfree(local->hw.wiphy->cipher_suites);
1444+
local->wiphy_ciphers_allocated = false;
1445+
}
14441446
kfree(local->int_scan_req);
14451447
return result;
14461448
}
@@ -1508,8 +1510,10 @@ void ieee80211_free_hw(struct ieee80211_hw *hw)
15081510
mutex_destroy(&local->iflist_mtx);
15091511
mutex_destroy(&local->mtx);
15101512

1511-
if (local->wiphy_ciphers_allocated)
1513+
if (local->wiphy_ciphers_allocated) {
15121514
kfree(local->hw.wiphy->cipher_suites);
1515+
local->wiphy_ciphers_allocated = false;
1516+
}
15131517

15141518
idr_for_each(&local->ack_status_frames,
15151519
ieee80211_free_ack_frame, NULL);

0 commit comments

Comments
 (0)