* [PATCH v2] scsi: ufs: mcq: Fix memory allocation checks for SQE and CQE
@ 2025-09-07 19:40 Alok Tiwari
2025-09-08 8:50 ` Manivannan Sadhasivam
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alok Tiwari @ 2025-09-07 19:40 UTC (permalink / raw)
To: mani, quic_cang, quic_asutoshd, peter.wang, martin.petersen,
alim.akhtar, avri.altman, bvanassche, James.Bottomley, linux-scsi
Cc: alok.a.tiwari, linux-kernel
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>
---
v1 -> v2
rephrase commit message and added Reviewed-by Alim
---
drivers/ufs/core/ufs-mcq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
index 1e50675772fe..cc88aaa106da 100644
--- a/drivers/ufs/core/ufs-mcq.c
+++ b/drivers/ufs/core/ufs-mcq.c
@@ -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;
}
--
2.50.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] scsi: ufs: mcq: Fix memory allocation checks for SQE and CQE
2025-09-07 19:40 [PATCH v2] scsi: ufs: mcq: Fix memory allocation checks for SQE and CQE Alok Tiwari
@ 2025-09-08 8:50 ` Manivannan Sadhasivam
2025-09-08 12:06 ` Peter Wang (王信友)
2025-09-10 3:04 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Manivannan Sadhasivam @ 2025-09-08 8:50 UTC (permalink / raw)
To: Alok Tiwari
Cc: quic_cang, quic_asutoshd, peter.wang, martin.petersen,
alim.akhtar, avri.altman, bvanassche, James.Bottomley, linux-scsi,
linux-kernel
On Sun, Sep 07, 2025 at 12:40:16PM GMT, Alok Tiwari wrote:
> 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: Manivannan Sadhasivam <mani@kernel.org>
- Mani
> Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
> ---
> v1 -> v2
> rephrase commit message and added Reviewed-by Alim
> ---
> drivers/ufs/core/ufs-mcq.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
> index 1e50675772fe..cc88aaa106da 100644
> --- a/drivers/ufs/core/ufs-mcq.c
> +++ b/drivers/ufs/core/ufs-mcq.c
> @@ -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;
> }
> --
> 2.50.1
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] scsi: ufs: mcq: Fix memory allocation checks for SQE and CQE
2025-09-07 19:40 [PATCH v2] scsi: ufs: mcq: Fix memory allocation checks for SQE and CQE Alok Tiwari
2025-09-08 8:50 ` Manivannan Sadhasivam
@ 2025-09-08 12:06 ` Peter Wang (王信友)
2025-09-10 3:04 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Peter Wang (王信友) @ 2025-09-08 12:06 UTC (permalink / raw)
To: avri.altman@wdc.com, quic_asutoshd@quicinc.com,
quic_cang@quicinc.com, alok.a.tiwari@oracle.com,
linux-scsi@vger.kernel.org, bvanassche@acm.org,
alim.akhtar@samsung.com, mani@kernel.org,
martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com
Cc: linux-kernel@vger.kernel.org
On Sun, 2025-09-07 at 12:40 -0700, Alok Tiwari wrote:
>
> 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>
> ---
> v1 -> v2
> rephrase commit message and added Reviewed-by Alim
> ---
> drivers/ufs/core/ufs-mcq.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
> index 1e50675772fe..cc88aaa106da 100644
> --- a/drivers/ufs/core/ufs-mcq.c
> +++ b/drivers/ufs/core/ufs-mcq.c
> @@ -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;
> }
> --
> 2.50.1
>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] scsi: ufs: mcq: Fix memory allocation checks for SQE and CQE
2025-09-07 19:40 [PATCH v2] scsi: ufs: mcq: Fix memory allocation checks for SQE and CQE Alok Tiwari
2025-09-08 8:50 ` Manivannan Sadhasivam
2025-09-08 12:06 ` Peter Wang (王信友)
@ 2025-09-10 3:04 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2025-09-10 3:04 UTC (permalink / raw)
To: mani, quic_cang, quic_asutoshd, peter.wang, alim.akhtar,
avri.altman, bvanassche, James.Bottomley, linux-scsi, Alok Tiwari
Cc: Martin K . Petersen, linux-kernel
On Sun, 07 Sep 2025 12:40:16 -0700, Alok Tiwari wrote:
> 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.
>
> [...]
Applied to 6.17/scsi-fixes, thanks!
[1/1] scsi: ufs: mcq: Fix memory allocation checks for SQE and CQE
https://git.kernel.org/mkp/scsi/c/5cb782ff3c62
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-09-10 3:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-07 19:40 [PATCH v2] scsi: ufs: mcq: Fix memory allocation checks for SQE and CQE Alok Tiwari
2025-09-08 8:50 ` Manivannan Sadhasivam
2025-09-08 12:06 ` Peter Wang (王信友)
2025-09-10 3:04 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox