Message ID | 20211222100005.1212589-1-jiasheng@iscas.ac.cn |
---|---|
State | New |
Headers | show |
Series | usb: gadget: udc: mv_udc_core: Check error dma address | expand |
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; }
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 <jiasheng@iscas.ac.cn> --- drivers/usb/gadget/udc/mv_udc_core.c | 3 +++ 1 file changed, 3 insertions(+)