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: 8aa0abda8b ("Merge e1a7aa25ff ("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 <bvanassche@google.com>
This commit is contained in:
Bart Van Assche
2022-12-01 09:24:25 -08:00
committed by Treehugger Robot
parent e8634696c7
commit bfdfddfecd

View File

@@ -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 ||