]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: ath11k: validate ath11k_crypto_mode on top of ath11k_core_qmi_firmware_ready
authorRodrigo Gobbi <rodrigo.gobbi.7@gmail.com>
Thu, 22 May 2025 20:01:12 +0000 (17:01 -0300)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Sat, 7 Jun 2025 14:36:03 +0000 (07:36 -0700)
if ath11k_crypto_mode is invalid (not ATH11K_CRYPT_MODE_SW/ATH11K_CRYPT_MODE_HW),
ath11k_core_qmi_firmware_ready() will not undo some actions that was previously
started/configured. Do the validation as soon as possible in order to avoid
undoing actions in that case and also to fix the following smatch warning:

drivers/net/wireless/ath/ath11k/core.c:2166 ath11k_core_qmi_firmware_ready()
warn: missing unwind goto?

Signed-off-by: Rodrigo Gobbi <rodrigo.gobbi.7@gmail.com>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/r/202304151955.oqAetVFd-lkp@intel.com/
Fixes: aa2092a9bab3 ("ath11k: add raw mode and software crypto support")
Reviewed-by: Baochen Qiang <quic_bqiang@quicinc.com>
Link: https://patch.msgid.link/20250522200519.16858-1-rodrigo.gobbi.7@gmail.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath11k/core.c

index c8c5008be7f26a8502050796979d980c8b992279..22a10113613503bb2cf97185d2f6ccd7921e243d 100644 (file)
@@ -2135,6 +2135,20 @@ int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)
 {
        int ret;
 
+       switch (ath11k_crypto_mode) {
+       case ATH11K_CRYPT_MODE_SW:
+               set_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags);
+               set_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);
+               break;
+       case ATH11K_CRYPT_MODE_HW:
+               clear_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags);
+               clear_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);
+               break;
+       default:
+               ath11k_info(ab, "invalid crypto_mode: %d\n", ath11k_crypto_mode);
+               return -EINVAL;
+       }
+
        ret = ath11k_core_start_firmware(ab, ab->fw_mode);
        if (ret) {
                ath11k_err(ab, "failed to start firmware: %d\n", ret);
@@ -2153,20 +2167,6 @@ int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)
                goto err_firmware_stop;
        }
 
-       switch (ath11k_crypto_mode) {
-       case ATH11K_CRYPT_MODE_SW:
-               set_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags);
-               set_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);
-               break;
-       case ATH11K_CRYPT_MODE_HW:
-               clear_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags);
-               clear_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);
-               break;
-       default:
-               ath11k_info(ab, "invalid crypto_mode: %d\n", ath11k_crypto_mode);
-               return -EINVAL;
-       }
-
        if (ath11k_frame_mode == ATH11K_HW_TXRX_RAW)
                set_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags);