usb: dwc3: use proper function for setting endpoint name
authorAnton Tikhomirov <av.tikhomirov@samsung.com>
Thu, 23 Feb 2012 06:38:46 +0000 (15:38 +0900)
committerFelipe Balbi <balbi@ti.com>
Fri, 2 Mar 2012 10:12:04 +0000 (12:12 +0200)
It's wrong to use the size of array as an argument for strncat.
Memory corruption is possible. strlcat is exactly what we need here.

Cc: stable@vger.kernel.org
Signed-off-by: Anton Tikhomirov <av.tikhomirov@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc3/gadget.c

index 48b2d0d14481a4173efaa6e3371faf516222a87b..60b75c302aa42fb0827ebaa3d3df1bf4562e1aca 100644 (file)
@@ -643,16 +643,16 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep,
 
        switch (usb_endpoint_type(desc)) {
        case USB_ENDPOINT_XFER_CONTROL:
-               strncat(dep->name, "-control", sizeof(dep->name));
+               strlcat(dep->name, "-control", sizeof(dep->name));
                break;
        case USB_ENDPOINT_XFER_ISOC:
-               strncat(dep->name, "-isoc", sizeof(dep->name));
+               strlcat(dep->name, "-isoc", sizeof(dep->name));
                break;
        case USB_ENDPOINT_XFER_BULK:
-               strncat(dep->name, "-bulk", sizeof(dep->name));
+               strlcat(dep->name, "-bulk", sizeof(dep->name));
                break;
        case USB_ENDPOINT_XFER_INT:
-               strncat(dep->name, "-int", sizeof(dep->name));
+               strlcat(dep->name, "-int", sizeof(dep->name));
                break;
        default:
                dev_err(dwc->dev, "invalid endpoint transfer type\n");