Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 06d9db72 authored by Kishon Vijay Abraham I's avatar Kishon Vijay Abraham I Committed by Felipe Balbi
Browse files

usb: musb: gadget: do *unmap_dma_buffer* only for valid DMA addr



musb does not use DMA buffer for ep0 but it uses the same giveback
function *musb_g_giveback* for all endpoints (*musb_g_ep0_giveback* calls
*musb_g_giveback*). So for ep0 case request.dma will be '0'
and will result in kernel OOPS if tried to *unmap_dma_buffer* for requests in
ep0. Fixed it by doing *unmap_dma_buffer* only for valid DMA addr and
checking that musb_ep->dma is valid when unmapping.

Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 273daf2f
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -141,7 +141,9 @@ static inline void map_dma_buffer(struct musb_request *request,
static inline void unmap_dma_buffer(struct musb_request *request,
static inline void unmap_dma_buffer(struct musb_request *request,
				struct musb *musb)
				struct musb *musb)
{
{
	if (!is_buffer_mapped(request))
	struct musb_ep *musb_ep = request->ep;

	if (!is_buffer_mapped(request) || !musb_ep->dma)
		return;
		return;


	if (request->request.dma == DMA_ADDR_INVALID) {
	if (request->request.dma == DMA_ADDR_INVALID) {
@@ -195,7 +197,10 @@ __acquires(ep->musb->lock)


	ep->busy = 1;
	ep->busy = 1;
	spin_unlock(&musb->lock);
	spin_unlock(&musb->lock);

	if (!dma_mapping_error(&musb->g.dev, request->dma))
		unmap_dma_buffer(req, musb);
		unmap_dma_buffer(req, musb);

	if (request->status == 0)
	if (request->status == 0)
		dev_dbg(musb->controller, "%s done request %p,  %d/%d\n",
		dev_dbg(musb->controller, "%s done request %p,  %d/%d\n",
				ep->end_point.name, request,
				ep->end_point.name, request,