diff mbox series

[v3,2/3] wifi: mwifiex: fix key_mgmt setting

Message ID 20240723-mwifiex-wpa-psk-sha256-v3-2-025168a91da1@pengutronix.de (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series mwifiex: add support for WPA-PSK-SHA256 | expand

Commit Message

Sascha Hauer July 23, 2024, 7:09 a.m. UTC
bss_config->key_mgmt specifies the AKM suites that are usable in
hardware. This variable is set to specific values while iterating
over the advertised AKM suites. This means the final value of the
variable depends on the order of the entries in the AKM suites
array. Instead of setting the variable, just set the relevant bits
in the key_mgmt bit field to make us independent of the order of
entries.
This behaviour is derived from the downstream driver that does the
same.
Also, set bss_config->key_mgmt to zero explicitly right before the
loop. bss_config has been zero allocated by the caller already, but
do so again to safe the reader from following the code path.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/wireless/marvell/mwifiex/uap_cmd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Francesco Dolcini July 23, 2024, 7:52 a.m. UTC | #1
On Tue, Jul 23, 2024 at 09:09:58AM +0200, Sascha Hauer wrote:
> bss_config->key_mgmt specifies the AKM suites that are usable in
> hardware. This variable is set to specific values while iterating
> over the advertised AKM suites. This means the final value of the
> variable depends on the order of the entries in the AKM suites
> array. Instead of setting the variable, just set the relevant bits
> in the key_mgmt bit field to make us independent of the order of
> entries.
> This behaviour is derived from the downstream driver that does the
> same.
> Also, set bss_config->key_mgmt to zero explicitly right before the
> loop. bss_config has been zero allocated by the caller already, but
> do so again to safe the reader from following the code path.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com>

Francesco
Brian Norris July 23, 2024, 5:10 p.m. UTC | #2
On Tue, Jul 23, 2024 at 09:09:58AM +0200, Sascha Hauer wrote:
> bss_config->key_mgmt specifies the AKM suites that are usable in
> hardware. This variable is set to specific values while iterating
> over the advertised AKM suites. This means the final value of the
> variable depends on the order of the entries in the AKM suites
> array. Instead of setting the variable, just set the relevant bits
> in the key_mgmt bit field to make us independent of the order of
> entries.
> This behaviour is derived from the downstream driver that does the
> same.
> Also, set bss_config->key_mgmt to zero explicitly right before the
> loop. bss_config has been zero allocated by the caller already, but
> do so again to safe the reader from following the code path.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  drivers/net/wireless/marvell/mwifiex/uap_cmd.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Acked-by: Brian Norris <briannorris@chromium.org>
diff mbox series

Patch

diff --git a/drivers/net/wireless/marvell/mwifiex/uap_cmd.c b/drivers/net/wireless/marvell/mwifiex/uap_cmd.c
index 7f822660fd955..57280eaae483c 100644
--- a/drivers/net/wireless/marvell/mwifiex/uap_cmd.c
+++ b/drivers/net/wireless/marvell/mwifiex/uap_cmd.c
@@ -52,13 +52,14 @@  int mwifiex_set_secure_params(struct mwifiex_private *priv,
 	if (params->crypto.wpa_versions & NL80211_WPA_VERSION_2)
 		bss_config->protocol |= PROTOCOL_WPA2;
 
+	bss_config->key_mgmt = 0;
 	for (i = 0; i < params->crypto.n_akm_suites; i++) {
 		switch (params->crypto.akm_suites[i]) {
 		case WLAN_AKM_SUITE_8021X:
-			bss_config->key_mgmt = KEY_MGMT_EAP;
+			bss_config->key_mgmt |= KEY_MGMT_EAP;
 			break;
 		case WLAN_AKM_SUITE_PSK:
-			bss_config->key_mgmt = KEY_MGMT_PSK;
+			bss_config->key_mgmt |= KEY_MGMT_PSK;
 			break;
 		default:
 			break;