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

Commit 019de689 authored by Ram Prakash Gupta's avatar Ram Prakash Gupta
Browse files

mmc: cqhci: End crypto if descriptor fails



Crypto configuration may go out of sync, in case
descriptor preparation fails, and may lead to data
corruption.

Reference:
9aab11:
mmc: cmdq_hci: Remove runtime PM vote if request issuing fails.

Change-Id: I7e4fcbb452acd86ab6cb0f59ef4602b584c0f3cb
Signed-off-by: default avatarVeerabhadrarao Badiganti <vbadigan@codeaurora.org>
Signed-off-by: default avatarRam Prakash Gupta <rampraka@codeaurora.org>
parent 53b18c6c
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -678,6 +678,7 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
		if (cq_host->ops->crypto_cfg) {
			err = cq_host->ops->crypto_cfg(mmc, mrq, tag, &ice_ctx);
			if (err) {
				mmc->err_stats[MMC_ERR_ICE_CFG]++;
				pr_err("%s: failed to configure crypto: err %d tag %d\n",
						mmc_hostname(mmc), err, tag);
				goto out;
@@ -692,7 +693,7 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
		if (err) {
			pr_err("%s: cqhci: failed to setup tx desc: %d\n",
			       mmc_hostname(mmc), err);
			return err;
			goto end_crypto;
		}
		/* PM QoS */
		sdhci_msm_pm_qos_irq_vote(host);
@@ -731,6 +732,20 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)

	if (err)
		cqhci_post_req(mmc, mrq);

	goto out;

end_crypto:
	if (cq_host->ops->crypto_cfg_end && mrq->data) {
		err = cq_host->ops->crypto_cfg_end(mmc, mrq);
		if (err)
			pr_err("%s: failed to end ice config: err %d tag %d\n",
					mmc_hostname(mmc), err, tag);
	}
	if (!(cq_host->caps & CQHCI_CAP_CRYPTO_SUPPORT) &&
			cq_host->ops->crypto_cfg_reset && mrq->data)
		cq_host->ops->crypto_cfg_reset(mmc, tag);

out:
	return err;
}