From: Thomas Fourier <fourier.thomas@gmail.com>
Cc: "Thomas Fourier" <fourier.thomas@gmail.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Jonathan Hunter" <jonathanh@nvidia.com>,
"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
"Wayne Chang" <waynec@nvidia.com>,
"Felipe Balbi" <felipe.balbi@linux.intel.com>,
"Nagarjuna Kristam" <nkristam@nvidia.com>,
linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] usb: gadget: Fix trb_virt_to_phys() error value
Date: Fri, 25 Jul 2025 11:05:33 +0200 [thread overview]
Message-ID: <20250725090540.51958-1-fourier.thomas@gmail.com> (raw)
0 is a valid DMA address, so returning DMA_MAPPING_ERROR in
trb_virt_to_phys(). Also, dma_mapping_error() wouldn't
flag 0 as an error address.
Checking the return value directly because the dma_addr
does not come directly from dma_map().
Fixes: 49db427232fe ("usb: gadget: Add UDC driver for tegra XUSB device mode controller")
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
drivers/usb/gadget/udc/tegra-xudc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c
index 2957316fd3d0..5dd3452bddbc 100644
--- a/drivers/usb/gadget/udc/tegra-xudc.c
+++ b/drivers/usb/gadget/udc/tegra-xudc.c
@@ -900,7 +900,7 @@ static dma_addr_t trb_virt_to_phys(struct tegra_xudc_ep *ep,
index = trb - ep->transfer_ring;
if (WARN_ON(index >= XUDC_TRANSFER_RING_SIZE))
- return 0;
+ return DMA_MAPPING_ERROR;
return (ep->transfer_ring_phys + index * sizeof(*trb));
}
@@ -1480,7 +1480,7 @@ __tegra_xudc_ep_dequeue(struct tegra_xudc_ep *ep,
deq_ptr = trb_virt_to_phys(ep,
&ep->transfer_ring[ep->enq_ptr]);
- if (dma_mapping_error(xudc->dev, deq_ptr)) {
+ if (deq_ptr == DMA_MAPPING_ERROR) {
ret = -EINVAL;
} else {
ep_ctx_write_deq_ptr(ep->context, deq_ptr);
@@ -2836,7 +2836,7 @@ static void tegra_xudc_reset(struct tegra_xudc *xudc)
deq_ptr = trb_virt_to_phys(ep0, &ep0->transfer_ring[ep0->deq_ptr]);
- if (!dma_mapping_error(xudc->dev, deq_ptr)) {
+ if (deq_ptr != DMA_MAPPING_ERROR) {
ep_ctx_write_deq_ptr(ep0->context, deq_ptr);
ep_ctx_write_dcs(ep0->context, ep0->pcs);
}
--
2.43.0
next reply other threads:[~2025-07-25 9:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-25 9:05 Thomas Fourier [this message]
2025-07-25 9:44 ` [PATCH] usb: gadget: Fix trb_virt_to_phys() error value Greg Kroah-Hartman
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=20250725090540.51958-1-fourier.thomas@gmail.com \
--to=fourier.thomas@gmail.com \
--cc=felipe.balbi@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nkristam@nvidia.com \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@baylibre.com \
--cc=waynec@nvidia.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;
as well as URLs for NNTP newsgroup(s).