Commit a3eca817 authored by Johannes Berg's avatar Johannes Berg

cfg80211: scan: use element finding functions in easy cases

There are a few easy cases where we only check for NULL or
have just simple use of the result, this can be done with
the element finding functions instead.

Link: https://lore.kernel.org/r/20210930131130.f27c8a7ec264.Iadb03c4307e9216e080ce513e8ad4048cd020b25@changeidSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 153e2a11
...@@ -383,7 +383,7 @@ static bool is_bss(struct cfg80211_bss *a, const u8 *bssid, ...@@ -383,7 +383,7 @@ static bool is_bss(struct cfg80211_bss *a, const u8 *bssid,
const u8 *ssid, size_t ssid_len) const u8 *ssid, size_t ssid_len)
{ {
const struct cfg80211_bss_ies *ies; const struct cfg80211_bss_ies *ies;
const u8 *ssidie; const struct element *ssid_elem;
if (bssid && !ether_addr_equal(a->bssid, bssid)) if (bssid && !ether_addr_equal(a->bssid, bssid))
return false; return false;
...@@ -394,12 +394,12 @@ static bool is_bss(struct cfg80211_bss *a, const u8 *bssid, ...@@ -394,12 +394,12 @@ static bool is_bss(struct cfg80211_bss *a, const u8 *bssid,
ies = rcu_access_pointer(a->ies); ies = rcu_access_pointer(a->ies);
if (!ies) if (!ies)
return false; return false;
ssidie = cfg80211_find_ie(WLAN_EID_SSID, ies->data, ies->len); ssid_elem = cfg80211_find_elem(WLAN_EID_SSID, ies->data, ies->len);
if (!ssidie) if (!ssid_elem)
return false; return false;
if (ssidie[1] != ssid_len) if (ssid_elem->datalen != ssid_len)
return false; return false;
return memcmp(ssidie + 2, ssid, ssid_len) == 0; return memcmp(ssid_elem->data, ssid, ssid_len) == 0;
} }
static int static int
...@@ -2072,12 +2072,12 @@ static void cfg80211_parse_mbssid_data(struct wiphy *wiphy, ...@@ -2072,12 +2072,12 @@ static void cfg80211_parse_mbssid_data(struct wiphy *wiphy,
if (!non_tx_data) if (!non_tx_data)
return; return;
if (!cfg80211_find_ie(WLAN_EID_MULTIPLE_BSSID, ie, ielen)) if (!cfg80211_find_elem(WLAN_EID_MULTIPLE_BSSID, ie, ielen))
return; return;
if (!wiphy->support_mbssid) if (!wiphy->support_mbssid)
return; return;
if (wiphy->support_only_he_mbssid && if (wiphy->support_only_he_mbssid &&
!cfg80211_find_ext_ie(WLAN_EID_EXT_HE_CAPABILITY, ie, ielen)) !cfg80211_find_ext_elem(WLAN_EID_EXT_HE_CAPABILITY, ie, ielen))
return; return;
new_ie = kmalloc(IEEE80211_MAX_DATA_LEN, gfp); new_ie = kmalloc(IEEE80211_MAX_DATA_LEN, gfp);
...@@ -2444,10 +2444,10 @@ cfg80211_inform_bss_frame_data(struct wiphy *wiphy, ...@@ -2444,10 +2444,10 @@ cfg80211_inform_bss_frame_data(struct wiphy *wiphy,
res = cfg80211_inform_single_bss_frame_data(wiphy, data, mgmt, res = cfg80211_inform_single_bss_frame_data(wiphy, data, mgmt,
len, gfp); len, gfp);
if (!res || !wiphy->support_mbssid || if (!res || !wiphy->support_mbssid ||
!cfg80211_find_ie(WLAN_EID_MULTIPLE_BSSID, ie, ielen)) !cfg80211_find_elem(WLAN_EID_MULTIPLE_BSSID, ie, ielen))
return res; return res;
if (wiphy->support_only_he_mbssid && if (wiphy->support_only_he_mbssid &&
!cfg80211_find_ext_ie(WLAN_EID_EXT_HE_CAPABILITY, ie, ielen)) !cfg80211_find_ext_elem(WLAN_EID_EXT_HE_CAPABILITY, ie, ielen))
return res; return res;
non_tx_data.tx_bss = res; non_tx_data.tx_bss = res;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment