From 1018b4e44f4f191c6e3c631c4eee35d0a112d32b Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Mon, 20 Sep 2010 10:32:04 +0300 Subject: [PATCH] usb: musb: gadget: fix DMA length for OUT transfer DMA length should not go beyond the availabe space of request buffer, so fix it. Signed-off-by: Ming Lei Acked-by: Anand Gadiyar Cc: David Brownell Cc: Anand Gadiyar Cc: Mike Frysinger Cc: Sergei Shtylyov Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/musb_gadget.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 176e1276dc28..f3ee04f2e17d 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -659,10 +659,11 @@ static void rxstate(struct musb *musb, struct musb_request *req) if (request->actual < request->length) { int transfer_size = 0; #ifdef USE_MODE1 - transfer_size = min(request->length, + transfer_size = min(request->length - request->actual, channel->max_len); #else - transfer_size = len; + transfer_size = min(request->length - request->actual, + (unsigned)len); #endif if (transfer_size <= musb_ep->packet_sz) musb_ep->dma->desired_mode = 0; -- 2.20.1