]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: ufs: mcq: Fix memory allocation checks for SQE and CQE
authorAlok Tiwari <alok.a.tiwari@oracle.com>
Sun, 7 Sep 2025 19:40:16 +0000 (12:40 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 10 Sep 2025 02:38:38 +0000 (22:38 -0400)
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: 4682abfae2eb ("scsi: ufs: core: mcq: Allocate memory for MCQ mode")
Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/core/ufs-mcq.c

index 1e50675772febbe93c0d5d543a8c77835c28e812..cc88aaa106da3060858f10a39e348141094de0af 100644 (file)
@@ -243,7 +243,7 @@ int ufshcd_mcq_memory_alloc(struct ufs_hba *hba)
                hwq->sqe_base_addr = dmam_alloc_coherent(hba->dev, utrdl_size,
                                                         &hwq->sqe_dma_addr,
                                                         GFP_KERNEL);
-               if (!hwq->sqe_dma_addr) {
+               if (!hwq->sqe_base_addr) {
                        dev_err(hba->dev, "SQE allocation failed\n");
                        return -ENOMEM;
                }
@@ -252,7 +252,7 @@ int ufshcd_mcq_memory_alloc(struct ufs_hba *hba)
                hwq->cqe_base_addr = dmam_alloc_coherent(hba->dev, cqe_size,
                                                         &hwq->cqe_dma_addr,
                                                         GFP_KERNEL);
-               if (!hwq->cqe_dma_addr) {
+               if (!hwq->cqe_base_addr) {
                        dev_err(hba->dev, "CQE allocation failed\n");
                        return -ENOMEM;
                }