From bfdfddfecdec2386487e091c833cd2e6774cb6c3 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 1 Dec 2022 09:24:25 -0800 Subject: [PATCH] ANDROID: scsi: ufs: Fix the command completion path ufshcd_crypto_clear_prdt() uses the lrbp->cmd pointer and hence must be called before that pointer is cleared. This patch brings the android-mainline command completion code in sync with the android14-5.15 branch. Bug: 259876933 Fixes: 8aa0abda8bd6 ("Merge e1a7aa25ff45 ("Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi") into android-mainline") Change-Id: I48852eb6623219bb249c4b309c48a651b6815b27 Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index ad93e3868e47..f851dc08d249 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -5366,6 +5366,7 @@ static void ufshcd_release_scsi_cmd(struct ufs_hba *hba, struct scsi_cmnd *cmd = lrbp->cmd; scsi_dma_unmap(cmd); + ufshcd_crypto_clear_prdt(hba, lrbp); lrbp->cmd = NULL; /* Mark the command as completed. */ ufshcd_release(hba); ufshcd_clk_scaling_update_busy(hba); @@ -5395,7 +5396,6 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, ufshcd_add_command_trace(hba, index, UFS_CMD_COMP); cmd->result = ufshcd_transfer_rsp_status(hba, lrbp); ufshcd_release_scsi_cmd(hba, lrbp); - ufshcd_crypto_clear_prdt(hba, lrbp); /* Do not touch lrbp after scsi done */ scsi_done(cmd); } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE ||