Skip to content

Commit c3b6847

Browse files
ebiggersAvenger-285714
authored andcommitted
scsi: ufs: qcom: Fix crypto key eviction
commit 7a0905caf5665be41094a6ceb5e9d2524de4627a upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c7c7009 commit c3b6847

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

drivers/ufs/host/ufs-qcom.c

+8-10
Original file line numberDiff line numberDiff line change
@@ -158,23 +158,21 @@ static int ufs_qcom_ice_program_key(struct ufs_hba *hba,
158158
{
159159
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
160160
union ufs_crypto_cap_entry cap;
161-
bool config_enable =
162-
cfg->config_enable & UFS_CRYPTO_CONFIGURATION_ENABLE;
161+
162+
if (!(cfg->config_enable & UFS_CRYPTO_CONFIGURATION_ENABLE))
163+
return qcom_ice_evict_key(host->ice, slot);
163164

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

170-
if (config_enable)
171-
return qcom_ice_program_key(host->ice,
172-
QCOM_ICE_CRYPTO_ALG_AES_XTS,
173-
QCOM_ICE_CRYPTO_KEY_SIZE_256,
174-
cfg->crypto_key,
175-
cfg->data_unit_size, slot);
176-
else
177-
return qcom_ice_evict_key(host->ice, slot);
171+
return qcom_ice_program_key(host->ice,
172+
QCOM_ICE_CRYPTO_ALG_AES_XTS,
173+
QCOM_ICE_CRYPTO_KEY_SIZE_256,
174+
cfg->crypto_key,
175+
cfg->data_unit_size, slot);
178176
}
179177

180178
#else

0 commit comments

Comments
 (0)