Skip to content

Commit

Permalink
scsi: ufs: qcom: Fix crypto key eviction
Browse files Browse the repository at this point in the history
Commit 56541c7 ("scsi: ufs: ufs-qcom: 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: 56541c7 ("scsi: ufs: ufs-qcom: Switch to the new ICE API")
Cc: [email protected]
Cc: Abel Vesa <[email protected]>
Signed-off-by: Eric Biggers <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Martin K. Petersen <[email protected]>
  • Loading branch information
ebiggers authored and martinkpetersen committed Jan 2, 2025
1 parent 5d10344 commit 7a0905c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions drivers/ufs/host/ufs-qcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,23 +155,21 @@ static int ufs_qcom_ice_program_key(struct ufs_hba *hba,
{
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
union ufs_crypto_cap_entry cap;
bool config_enable =
cfg->config_enable & UFS_CRYPTO_CONFIGURATION_ENABLE;

if (!(cfg->config_enable & UFS_CRYPTO_CONFIGURATION_ENABLE))
return qcom_ice_evict_key(host->ice, slot);

/* Only AES-256-XTS has been tested so far. */
cap = hba->crypto_cap_array[cfg->crypto_cap_idx];
if (cap.algorithm_id != UFS_CRYPTO_ALG_AES_XTS ||
cap.key_size != UFS_CRYPTO_KEY_SIZE_256)
return -EOPNOTSUPP;

if (config_enable)
return qcom_ice_program_key(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(host->ice, slot);
return qcom_ice_program_key(host->ice,
QCOM_ICE_CRYPTO_ALG_AES_XTS,
QCOM_ICE_CRYPTO_KEY_SIZE_256,
cfg->crypto_key,
cfg->data_unit_size, slot);
}

#else
Expand Down

0 comments on commit 7a0905c

Please sign in to comment.