mmc: sdhci-msm: fix crypto key eviction
authorEric Biggers <ebiggers@google.com>
Fri, 13 Dec 2024 04:19:48 +0000 (20:19 -0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Thu, 19 Dec 2024 13:42:10 +0000 (14:42 +0100)
Commit c7eed31e235c ("mmc: sdhci-msm: Switch to the new ICE API")
introduced an incorrect check of the algorithm ID into the key eviction
path, and thus qcom_ice_evict_key() is no longer ever called.  Fix it.

Fixes: c7eed31e235c ("mmc: sdhci-msm: Switch to the new ICE API")
Cc: stable@vger.kernel.org
Cc: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Message-ID: <20241213041958.202565-6-ebiggers@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/sdhci-msm.c

index e00208535bd1c6dd5a39ca7c73e45f419316937c..319f0ebbe652d63feed19469951054206b8e95d1 100644 (file)
@@ -1867,20 +1867,20 @@ static int sdhci_msm_program_key(struct cqhci_host *cq_host,
        struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
        union cqhci_crypto_cap_entry cap;
 
+       if (!(cfg->config_enable & CQHCI_CRYPTO_CONFIGURATION_ENABLE))
+               return qcom_ice_evict_key(msm_host->ice, slot);
+
        /* Only AES-256-XTS has been tested so far. */
        cap = cq_host->crypto_cap_array[cfg->crypto_cap_idx];
        if (cap.algorithm_id != CQHCI_CRYPTO_ALG_AES_XTS ||
                cap.key_size != CQHCI_CRYPTO_KEY_SIZE_256)
                return -EINVAL;
 
-       if (cfg->config_enable & CQHCI_CRYPTO_CONFIGURATION_ENABLE)
-               return qcom_ice_program_key(msm_host->ice,
-                                           QCOM_ICE_CRYPTO_ALG_AES_XTS,
-                                           QCOM_ICE_CRYPTO_KEY_SIZE_256,
-                                           cfg->crypto_key,
-                                           cfg->data_unit_size, slot);
-       else
-               return qcom_ice_evict_key(msm_host->ice, slot);
+       return qcom_ice_program_key(msm_host->ice,
+                                   QCOM_ICE_CRYPTO_ALG_AES_XTS,
+                                   QCOM_ICE_CRYPTO_KEY_SIZE_256,
+                                   cfg->crypto_key,
+                                   cfg->data_unit_size, slot);
 }
 
 #else /* CONFIG_MMC_CRYPTO */