summaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb
diff options
context:
space:
mode:
authorRobin Guo <guoweibin@inspur.com>2022-09-06 10:21:19 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-09-22 15:52:30 +0200
commiteea4c860c3b366369eff0489d94ee4f0571d467d (patch)
tree4c3e6bc5887f8ceff2266cc1cb17bb91079590e9 /drivers/usb/musb
parent93440d1fdf0a8d15857d755650fdcfc29c04e1f2 (diff)
downloadlinux-eea4c860c3b366369eff0489d94ee4f0571d467d.tar.gz
linux-eea4c860c3b366369eff0489d94ee4f0571d467d.tar.bz2
linux-eea4c860c3b366369eff0489d94ee4f0571d467d.zip
usb: musb: Fix musb_gadget.c rxstate overflow bug
The usb function device call musb_gadget_queue() adds the passed request to musb_ep::req_list,If the (request->length > musb_ep->packet_sz) and (is_buffer_mapped(req) return false),the rxstate() will copy all data in fifo to request->buf which may cause request->buf out of bounds. Fix it by add the length check : fifocnt = min_t(unsigned, request->length - request->actual, fifocnt); Signed-off-by: Robin Guo <guoweibin@inspur.com> Link: https://lore.kernel.org/r/20220906102119.1b071d07a8391ff115e6d1ef@inspur.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r--drivers/usb/musb/musb_gadget.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index daada4b66a92..6704a62a1665 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -760,6 +760,9 @@ static void rxstate(struct musb *musb, struct musb_request *req)
musb_writew(epio, MUSB_RXCSR, csr);
buffer_aint_mapped:
+ fifo_count = min_t(unsigned int,
+ request->length - request->actual,
+ (unsigned int)fifo_count);
musb_read_fifo(musb_ep->hw_ep, fifo_count, (u8 *)
(request->buf + request->actual));
request->actual += fifo_count;