hc
2023-11-06 e3e12f52b214121840b44c91de5b3e5af5d3eb84
kernel/net/wireless/sme.c
....@@ -796,12 +796,36 @@
796796 u8 *next;
797797
798798 if (params->bss) {
799
- /* Make sure the bss entry provided by the driver is valid. */
800799 struct cfg80211_internal_bss *ibss = bss_from_pub(params->bss);
801800
802
- if (WARN_ON(list_empty(&ibss->list))) {
803
- cfg80211_put_bss(wdev->wiphy, params->bss);
804
- return;
801
+ if (list_empty(&ibss->list)) {
802
+ struct cfg80211_bss *found = NULL, *tmp = params->bss;
803
+
804
+ found = cfg80211_get_bss(wdev->wiphy, NULL,
805
+ params->bss->bssid,
806
+ wdev->ssid, wdev->ssid_len,
807
+ wdev->conn_bss_type,
808
+ IEEE80211_PRIVACY_ANY);
809
+ if (found) {
810
+ /* The same BSS is already updated so use it
811
+ * instead, as it has latest info.
812
+ */
813
+ params->bss = found;
814
+ } else {
815
+ /* Update with BSS provided by driver, it will
816
+ * be freshly added and ref cnted, we can free
817
+ * the old one.
818
+ *
819
+ * signal_valid can be false, as we are not
820
+ * expecting the BSS to be found.
821
+ *
822
+ * keep the old timestamp to avoid confusion
823
+ */
824
+ cfg80211_bss_update(rdev, ibss, false,
825
+ ibss->ts);
826
+ }
827
+
828
+ cfg80211_put_bss(wdev->wiphy, tmp);
805829 }
806830 }
807831