Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 39e001a1 authored by Neeraj Soni's avatar Neeraj Soni Committed by ramandeep trehan
Browse files

security: pfe: Return proper error code



ICE clock funciton masks the error code from
scm call. This might introduce unwanted issues
in device. Ensure to return proper error code
to storage frameworks.

Change-Id: Ibd7358c3b19d23d5995cf267f56ef3bacf166569
Signed-off-by: default avatarRamandeep Trehan <rtrehan@codeaurora.org>
parent 71c76558
Loading
Loading
Loading
Loading
+19 −12
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ int qti_pfk_ice_set_key(uint32_t index, uint8_t *key, uint8_t *salt,
	int ret;
	char *tzbuf_key = (char *)ice_key;
	char *tzbuf_salt = (char *)ice_salt;
	char *s_type = storage_type;

	uint32_t smc_id = 0;
	u32 tzbuflen_key = sizeof(ice_key);
@@ -107,27 +108,31 @@ int qti_pfk_ice_set_key(uint32_t index, uint8_t *key, uint8_t *salt,
	desc.args[3] = virt_to_phys(tzbuf_salt);
	desc.args[4] = tzbuflen_salt;

	ret = qcom_ice_setup_ice_hw((const char *)storage_type, true);
	ret = qcom_ice_setup_ice_hw((const char *)s_type, true);

	if (ret) {
		pr_err("%s: could not enable clocks: 0x%x\n", __func__, ret);
		return ret;
		goto out;
	}

	ret = scm_call2(smc_id, &desc);

	ret = qcom_ice_setup_ice_hw((const char *)storage_type, false);

	pr_debug(" %s , ret = %d\n", __func__, ret);

	if (ret) {
		pr_err("%s: Error: 0x%x\n", __func__, ret);

		if (ret == -EBUSY) {
			goto out;
		} else {
			smc_id = TZ_ES_INVALIDATE_ICE_KEY_ID;
			desc.arginfo = TZ_ES_INVALIDATE_ICE_KEY_PARAM_ID;
			desc.args[0] = index;
			scm_call2(smc_id, &desc);
		}
	}

	ret = qcom_ice_setup_ice_hw((const char *)s_type, false);
out:
	return ret;
}

@@ -160,11 +165,13 @@ int qti_pfk_ice_invalidate_key(uint32_t index, char *storage_type)

	ret = scm_call2(smc_id, &desc);

	ret = qcom_ice_setup_ice_hw((const char *)storage_type, false);

	pr_debug(" %s , ret = %d\n", __func__, ret);
	if (ret)
	if (ret) {
		pr_err("%s: Error: 0x%x\n", __func__, ret);
		qcom_ice_setup_ice_hw((const char *)storage_type, false);
	} else {
		ret = qcom_ice_setup_ice_hw((const char *)storage_type, false);
	}

	return ret;