* [PATCH] usb: gadget: Fix trb_virt_to_phys() error value
@ 2025-07-25 9:05 Thomas Fourier
2025-07-25 9:44 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Fourier @ 2025-07-25 9:05 UTC (permalink / raw)
Cc: Thomas Fourier, Greg Kroah-Hartman, Thierry Reding,
Jonathan Hunter, Uwe Kleine-König, Wayne Chang, Felipe Balbi,
Nagarjuna Kristam, linux-usb, linux-tegra, linux-kernel
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: gadget: Fix trb_virt_to_phys() error value
2025-07-25 9:05 [PATCH] usb: gadget: Fix trb_virt_to_phys() error value Thomas Fourier
@ 2025-07-25 9:44 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2025-07-25 9:44 UTC (permalink / raw)
To: Thomas Fourier
Cc: Thierry Reding, Jonathan Hunter, Uwe Kleine-König,
Wayne Chang, Felipe Balbi, Nagarjuna Kristam, linux-usb,
linux-tegra, linux-kernel
On Fri, Jul 25, 2025 at 11:05:33AM +0200, Thomas Fourier wrote:
> 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
>
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- You have marked a patch with a "Fixes:" tag for a commit that is in an
older released kernel, yet you do not have a cc: stable line in the
signed-off-by area at all, which means that the patch will not be
applied to any older kernel releases. To properly fix this, please
follow the documented rules in the
Documentation/process/stable-kernel-rules.rst file for how to resolve
this.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-25 9:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-25 9:05 [PATCH] usb: gadget: Fix trb_virt_to_phys() error value Thomas Fourier
2025-07-25 9:44 ` Greg Kroah-Hartman
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).