From: Roel Kluin <roel.kluin@xxxxxxxxx> Check whether index is within bounds before testing the element. Signed-off-by: Roel Kluin <roel.kluin@xxxxxxxxx> Cc: David Brownell <david-b@xxxxxxxxxxx> Cc: Greg KH <greg@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/usb/gadget/composite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff -puN drivers/usb/gadget/composite.c~usb-gadget-read-buffer-overflow drivers/usb/gadget/composite.c --- a/drivers/usb/gadget/composite.c~usb-gadget-read-buffer-overflow +++ a/drivers/usb/gadget/composite.c @@ -602,7 +602,7 @@ static int get_string(struct usb_composi } } - for (len = 0; s->wData[len] && len <= 126; len++) + for (len = 0; len <= 126 && s->wData[len]; len++) continue; if (!len) return -EINVAL; _ -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html