lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251229135853.33222-1-fourier.thomas@gmail.com>
Date: Mon, 29 Dec 2025 14:58:49 +0100
From: Thomas Fourier <fourier.thomas@...il.com>
To: 
Cc: Thomas Fourier <fourier.thomas@...il.com>,
	stable@...r.kernel.org,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Thierry Reding <thierry.reding@...il.com>,
	Jonathan Hunter <jonathanh@...dia.com>,
	Wayne Chang <waynec@...dia.com>,
	Haotien Hsu <haotienh@...dia.com>,
	"Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
	Liao Yuanhong <liaoyuanhong@...o.com>,
	Nagarjuna Kristam <nkristam@...dia.com>,
	Felipe Balbi <felipe.balbi@...ux.intel.com>,
	linux-usb@...r.kernel.org,
	linux-tegra@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH v2] usb: gadget: Fix trb_virt_to_phys() error value

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")
Cc: <stable@...r.kernel.org>
Signed-off-by: Thomas Fourier <fourier.thomas@...il.com>
---
v1->v2:
  - Add Cc: tag
 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 9d2007f448c0..63f7eeddb401 100644
--- a/drivers/usb/gadget/udc/tegra-xudc.c
+++ b/drivers/usb/gadget/udc/tegra-xudc.c
@@ -904,7 +904,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));
 }
@@ -1484,7 +1484,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);
@@ -2834,7 +2834,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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ