From 1e0abb7e1844a7cb499321a94d5d04347ef86d68 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Tue, 12 May 2009 13:50:34 -0700 Subject: USB: imx_udc: fix leak in imx_ep_alloc_request() cppcheck found another leak in drivers/usb/gadget/imx_udc.c Cc: Mike Lee Cc: Darius Augulis Signed-off-by: Daniel Mack Cc: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/imx_udc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers/usb/gadget/imx_udc.c') diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c index 168658b4b4e..239bf8ed9f4 100644 --- a/drivers/usb/gadget/imx_udc.c +++ b/drivers/usb/gadget/imx_udc.c @@ -734,9 +734,12 @@ static struct usb_request *imx_ep_alloc_request { struct imx_request *req; + if (!usb_ep) + return NULL; + req = kzalloc(sizeof *req, gfp_flags); - if (!req || !usb_ep) - return 0; + if (!req) + return NULL; INIT_LIST_HEAD(&req->queue); req->in_use = 0; -- cgit v1.2.3 From 680cc64557101eaaca706dc9a1a0777f35aac0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gl=C3=B6ckner?= Date: Thu, 28 May 2009 13:00:14 +0200 Subject: USB: gadget: imx_udc: don't queue more data when zlp is to be sent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a zero-length packet has been requested and another packet is written into the fifo, the MX1 tends to send the first byte of the previous packet instead of the first byte of the current packet. The CRC is adjusted accordingly so that this packet is _not_ discarded by the host. Waiting for the ZLPS bit to clear avoids these bad packets. Signed-off-by: Daniel Glöckner Cc: Darius Augulis Cc: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/imx_udc.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers/usb/gadget/imx_udc.c') diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c index 239bf8ed9f4..c52a681f376 100644 --- a/drivers/usb/gadget/imx_udc.c +++ b/drivers/usb/gadget/imx_udc.c @@ -415,6 +415,13 @@ static int write_packet(struct imx_ep_struct *imx_ep, struct imx_request *req) u8 *buf; int length, count, temp; + if (unlikely(__raw_readl(imx_ep->imx_usb->base + + USB_EP_STAT(EP_NO(imx_ep))) & EPSTAT_ZLPS)) { + D_TRX(imx_ep->imx_usb->dev, "<%s> zlp still queued in EP %s\n", + __func__, imx_ep->ep.name); + return -1; + } + buf = req->req.buf + req->req.actual; prefetch(buf); -- cgit v1.2.3