Skip to content

Commit 04c116e

Browse files
quic-cangmartinkpetersen
authored andcommitted
scsi: ufs: core: Let the sq_lock protect sq_tail_slot access
When accessing sq_tail_slot without protection from sq_lock, a race condition can cause multiple SQEs to be copied to duplicate SQE slots. This can lead to multiple stability issues. Fix this by moving the *dest initialization in ufshcd_send_command() back under protection from the sq_lock. Fixes: 3c85f08 ("scsi: ufs: mcq: Use pointer arithmetic in ufshcd_send_command()") Signed-off-by: Can Guo <quic_cang@quicinc.com> Link: https://lore.kernel.org/r/1702913550-20631-1-git-send-email-quic_cang@quicinc.com Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 9264fd6 commit 04c116e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2274,9 +2274,10 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag,
22742274
if (is_mcq_enabled(hba)) {
22752275
int utrd_size = sizeof(struct utp_transfer_req_desc);
22762276
struct utp_transfer_req_desc *src = lrbp->utr_descriptor_ptr;
2277-
struct utp_transfer_req_desc *dest = hwq->sqe_base_addr + hwq->sq_tail_slot;
2277+
struct utp_transfer_req_desc *dest;
22782278

22792279
spin_lock(&hwq->sq_lock);
2280+
dest = hwq->sqe_base_addr + hwq->sq_tail_slot;
22802281
memcpy(dest, src, utrd_size);
22812282
ufshcd_inc_sq_tail(hwq);
22822283
spin_unlock(&hwq->sq_lock);

0 commit comments

Comments
 (0)