From 927d0424342ccb4865e0436a4241f40e5f523dc7 Mon Sep 17 00:00:00 2001 From: Vaibhav Agrawal Date: Wed, 30 Jun 2021 11:21:25 +0530 Subject: [PATCH] soc: qcom: Return correct error code when program_key fails fails When we call crypto_qti_program_key to program the key, and it fails due to trustzone busy issue, we try to call invalidate key method just after that, and in the process, overwrite the error code returned by the program key failure. Fix this by handling the errors from both program key and invalidate key separately, and return the program key error code to caller. Test: Verified device boot up and reboot. Change-Id: Iaff0844f68b4886c23e1840d7e0e4a404d38fc96 Signed-off-by: Vaibhav Agrawal --- drivers/soc/qcom/crypto-qti-common.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/soc/qcom/crypto-qti-common.c b/drivers/soc/qcom/crypto-qti-common.c index 969956489cef..51a4a9beb10c 100644 --- a/drivers/soc/qcom/crypto-qti-common.c +++ b/drivers/soc/qcom/crypto-qti-common.c @@ -398,7 +398,7 @@ int crypto_qti_keyslot_program(void *priv_data, unsigned int slot, u8 data_unit_mask, int capid) { - int err = 0; + int err1 = 0, err2 = 0; struct crypto_vops_qti_entry *ice_entry; ice_entry = (struct crypto_vops_qti_entry *) priv_data; @@ -407,19 +407,19 @@ int crypto_qti_keyslot_program(void *priv_data, return -EINVAL; } - err = crypto_qti_program_key(ice_entry, key, slot, + err1 = crypto_qti_program_key(ice_entry, key, slot, data_unit_mask, capid); - if (err) { - pr_err("%s: program key failed with error %d\n", __func__, err); - err = crypto_qti_invalidate_key(ice_entry, slot); - if (err) { + if (err1) { + pr_err("%s: program key failed with error %d\n", + __func__, err1); + err2 = crypto_qti_invalidate_key(ice_entry, slot); + if (err2) { pr_err("%s: invalidate key failed with error %d\n", - __func__, err); - return err; + __func__, err2); } } - return err; + return err1; } int crypto_qti_keyslot_evict(void *priv_data, unsigned int slot)