[PATCH 2/3] usb: dwc2: fix mismatching argument to printf format specifier

Ahmad Fatoum ahmad at a3f.at
Sun Feb 28 14:07:06 EST 2021


%pad prints a DMA address out of a pointer to dma_addr_t.
Casting the dma_addr_t itself to void *, will lead to printf
dereferencing it and printing the first sizeof(dma_addr_t).

The dwc2 driver is the only one using %pad. Fix it.

Signed-off-by: Ahmad Fatoum <ahmad at a3f.at>
---
 drivers/usb/dwc2/gadget.c | 2 +-
 drivers/usb/dwc2/host.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index b8ec37be78b8..053a243d64c3 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -307,7 +307,7 @@ static void dwc2_gadget_start_req(struct dwc2 *dwc2,
 		dwc2_writel(dwc2, ureq->dma, dma_reg);
 
 		dwc2_dbg(dwc2, "%s: 0x%pad => 0x%08x\n",
-			 __func__, (void *)ureq->dma, dma_reg);
+			 __func__, &ureq->dma, dma_reg);
 	}
 
 	if (hs_ep->isochronous && hs_ep->interval == 1) {
diff --git a/drivers/usb/dwc2/host.c b/drivers/usb/dwc2/host.c
index 7a070d91f3bc..b5a51f566804 100644
--- a/drivers/usb/dwc2/host.c
+++ b/drivers/usb/dwc2/host.c
@@ -181,7 +181,7 @@ static int transfer_chunk(struct dwc2 *dwc2, u8 hc,
 	}
 
 	dwc2_dbg(dwc2, "chunk: pid=%d xfer_len=%u pkts=%u dma_addr=%pad\n",
-		 *pid, xfer_len, num_packets, (void *)dma_addr);
+		 *pid, xfer_len, num_packets, &dma_addr);
 
 	dwc2_writel(dwc2, dma_addr, HCDMA(hc));
 
-- 
2.30.0




More information about the barebox mailing list