Skip to content

Commit

Permalink
wifi: virt_wifi: don't use strlen() in const context
Browse files Browse the repository at this point in the history
Looks like not all compilers allow strlen(constant) as
a constant, so don't do that. Instead, revert back to
defining the length as the first submission had it.

Fixes: b5d14b0 ("wifi: virt_wifi: avoid reporting connection success with wrong SSID")
Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Johannes Berg <[email protected]>
  • Loading branch information
jmberg-intel committed Jul 9, 2024
1 parent b360313 commit 6e909f4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/net/wireless/virtual/virt_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ static struct ieee80211_supported_band band_5ghz = {
static u8 fake_router_bssid[ETH_ALEN] __ro_after_init = {};

#define VIRT_WIFI_SSID "VirtWifi"
#define VIRT_WIFI_SSID_LEN 8

static void virt_wifi_inform_bss(struct wiphy *wiphy)
{
Expand All @@ -148,7 +149,7 @@ static void virt_wifi_inform_bss(struct wiphy *wiphy)
u8 ssid[8];
} __packed ssid = {
.tag = WLAN_EID_SSID,
.len = strlen(VIRT_WIFI_SSID),
.len = VIRT_WIFI_SSID_LEN,
.ssid = VIRT_WIFI_SSID,
};

Expand Down Expand Up @@ -262,7 +263,7 @@ static void virt_wifi_connect_complete(struct work_struct *work)
container_of(work, struct virt_wifi_netdev_priv, connect.work);
u8 *requested_bss = priv->connect_requested_bss;
bool right_addr = ether_addr_equal(requested_bss, fake_router_bssid);
bool right_ssid = priv->connect_requested_ssid_len == strlen(VIRT_WIFI_SSID) &&
bool right_ssid = priv->connect_requested_ssid_len == VIRT_WIFI_SSID_LEN &&
!memcmp(priv->connect_requested_ssid, VIRT_WIFI_SSID,
priv->connect_requested_ssid_len);
u16 status = WLAN_STATUS_SUCCESS;
Expand Down

0 comments on commit 6e909f4

Please sign in to comment.