Skip to content

Commit 5cb782f

Browse files
aloktiwamartinkpetersen
authored andcommitted
scsi: ufs: mcq: Fix memory allocation checks for SQE and CQE
Previous checks incorrectly tested the DMA addresses (dma_handle) for NULL. Since dma_alloc_coherent() returns the CPU (virtual) address, the NULL check should be performed on the *_base_addr pointer to correctly detect allocation failures. Update the checks to validate sqe_base_addr and cqe_base_addr instead of sqe_dma_addr and cqe_dma_addr. Fixes: 4682abf ("scsi: ufs: core: mcq: Allocate memory for MCQ mode") Signed-off-by: Alok Tiwari <[email protected]> Reviewed-by: Alim Akhtar <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Peter Wang <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 708e237 commit 5cb782f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/ufs/core/ufs-mcq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ int ufshcd_mcq_memory_alloc(struct ufs_hba *hba)
243243
hwq->sqe_base_addr = dmam_alloc_coherent(hba->dev, utrdl_size,
244244
&hwq->sqe_dma_addr,
245245
GFP_KERNEL);
246-
if (!hwq->sqe_dma_addr) {
246+
if (!hwq->sqe_base_addr) {
247247
dev_err(hba->dev, "SQE allocation failed\n");
248248
return -ENOMEM;
249249
}
@@ -252,7 +252,7 @@ int ufshcd_mcq_memory_alloc(struct ufs_hba *hba)
252252
hwq->cqe_base_addr = dmam_alloc_coherent(hba->dev, cqe_size,
253253
&hwq->cqe_dma_addr,
254254
GFP_KERNEL);
255-
if (!hwq->cqe_dma_addr) {
255+
if (!hwq->cqe_base_addr) {
256256
dev_err(hba->dev, "CQE allocation failed\n");
257257
return -ENOMEM;
258258
}

0 commit comments

Comments
 (0)