From: "Peter Wang (王信友)" <peter.wang@mediatek.com>
To: "avri.altman@wdc.com" <avri.altman@wdc.com>,
"quic_asutoshd@quicinc.com" <quic_asutoshd@quicinc.com>,
"quic_cang@quicinc.com" <quic_cang@quicinc.com>,
"alok.a.tiwari@oracle.com" <alok.a.tiwari@oracle.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"bvanassche@acm.org" <bvanassche@acm.org>,
"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
"mani@kernel.org" <mani@kernel.org>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"James.Bottomley@HansenPartnership.com"
<James.Bottomley@HansenPartnership.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] scsi: ufs: mcq: Fix memory allocation checks for SQE and CQE
Date: Mon, 8 Sep 2025 12:06:20 +0000 [thread overview]
Message-ID: <3fc7d28a549bf013d320cf274513090ca0403b20.camel@mediatek.com> (raw)
In-Reply-To: <20250907194025.3611607-1-alok.a.tiwari@oracle.com>
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>
next prev parent reply other threads:[~2025-09-08 12:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 (王信友) [this message]
2025-09-10 3:04 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3fc7d28a549bf013d320cf274513090ca0403b20.camel@mediatek.com \
--to=peter.wang@mediatek.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=alim.akhtar@samsung.com \
--cc=alok.a.tiwari@oracle.com \
--cc=avri.altman@wdc.com \
--cc=bvanassche@acm.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mani@kernel.org \
--cc=martin.petersen@oracle.com \
--cc=quic_asutoshd@quicinc.com \
--cc=quic_cang@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox