Commit 3e7c2510 authored by Fabian Vogt's avatar Fabian Vogt Committed by Greg Kroah-Hartman

fotg210-udc: Don't DMA more than the buffer can take

Before this, it wrote as much as available into the buffer, even if it
didn't fit.

Fixes: b84a8dee ("usb: gadget: add Faraday fotg210_udc driver")
Signed-off-by: default avatarFabian Vogt <fabian@ritter-vogt.de>
Link: https://lore.kernel.org/r/20210324141115.9384-7-fabian@ritter-vogt.deSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fe8f103a
...@@ -338,8 +338,9 @@ static void fotg210_start_dma(struct fotg210_ep *ep, ...@@ -338,8 +338,9 @@ static void fotg210_start_dma(struct fotg210_ep *ep,
} else { } else {
buffer = req->req.buf + req->req.actual; buffer = req->req.buf + req->req.actual;
length = ioread32(ep->fotg210->reg + length = ioread32(ep->fotg210->reg +
FOTG210_FIBCR(ep->epnum - 1)); FOTG210_FIBCR(ep->epnum - 1)) & FIBCR_BCFX;
length &= FIBCR_BCFX; if (length > req->req.length - req->req.actual)
length = req->req.length - req->req.actual;
} }
} else { } else {
buffer = req->req.buf + req->req.actual; buffer = req->req.buf + req->req.actual;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment