]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
wifi: mac80211: fix memory free error when registering wiphy fail
authortaozhang <taozhang@bestechnic.com>
Sat, 15 Oct 2022 09:38:31 +0000 (17:38 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 21 Oct 2022 10:34:59 +0000 (12:34 +0200)
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>
net/mac80211/main.c

index 46f3eddc23887c78598a5349191419a3993acd8b..02b5abc7326bc52ea38ade9d19d1e5870110a3e1 100644 (file)
@@ -1439,8 +1439,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
        ieee80211_led_exit(local);
        destroy_workqueue(local->workqueue);
  fail_workqueue:
-       if (local->wiphy_ciphers_allocated)
+       if (local->wiphy_ciphers_allocated) {
                kfree(local->hw.wiphy->cipher_suites);
+               local->wiphy_ciphers_allocated = false;
+       }
        kfree(local->int_scan_req);
        return result;
 }
@@ -1508,8 +1510,10 @@ void ieee80211_free_hw(struct ieee80211_hw *hw)
        mutex_destroy(&local->iflist_mtx);
        mutex_destroy(&local->mtx);
 
-       if (local->wiphy_ciphers_allocated)
+       if (local->wiphy_ciphers_allocated) {
                kfree(local->hw.wiphy->cipher_suites);
+               local->wiphy_ciphers_allocated = false;
+       }
 
        idr_for_each(&local->ack_status_frames,
                     ieee80211_free_ack_frame, NULL);