usb: gadget: mv_u3d: add check for dma mapping error

mv_u3d_req_to_trb() does not check for dma mapping errors.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
This commit is contained in:
Alexey Khoroshilov 2016-11-03 16:16:31 +03:00 committed by Felipe Balbi
parent 5eb30cedce
commit 6ffd65154e
1 changed files with 6 additions and 0 deletions

View File

@ -462,6 +462,12 @@ static int mv_u3d_req_to_trb(struct mv_u3d_req *req)
req->trb_head->trb_hw,
trb_num * sizeof(*trb_hw),
DMA_BIDIRECTIONAL);
if (dma_mapping_error(u3d->gadget.dev.parent,
req->trb_head->trb_dma)) {
kfree(req->trb_head->trb_hw);
kfree(req->trb_head);
return -EFAULT;
}
req->chain = 1;
}