Because the dma_map_single() might return error dma address if fails.
Therefore it might be better to check the address in order to avoid the
use of error dma address in build_dtd() which is called by req_to_dtd().
Fixes: 90fccb529d24 ("usb: gadget: Gadget directory cleanup - group UDC drivers")
Signed-off-by: Jiasheng Jiang <[email protected]>
---
drivers/usb/gadget/udc/mv_udc_core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c
index 0fb4ef464321..2613dbdc5aba 100644
--- a/drivers/usb/gadget/udc/mv_udc_core.c
+++ b/drivers/usb/gadget/udc/mv_udc_core.c
@@ -1472,6 +1472,9 @@ udc_prime_status(struct mv_udc *udc, u8 direction, u16 status, bool empty)
req->req.dma = dma_map_single(ep->udc->gadget.dev.parent,
req->req.buf, req->req.length,
ep_dir(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
+ retval = dma_mapping_error(ep->udc->gadget.dev.parent, req->req.dma);
+ if (retval)
+ goto out;
req->mapped = 1;
}
--
2.25.1
Sorry, that is my fault.
I send the wrong patch.
Please ignore this one.
Sincerely thanks,
Jiasheng