From: Roel Kluin Date: Thu, 6 Aug 2009 23:09:51 +0000 (-0700) Subject: USB: gadget: Read buffer overflow X-Git-Tag: firefly_0821_release~12454^2~67 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=417b57b3e4e34df07a2aceaf75baffeacdd9385f;p=firefly-linux-kernel-4.4.55.git USB: gadget: Read buffer overflow Check whether index is within bounds before testing the element. Signed-off-by: Roel Kluin Cc: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 59e85234fa0a..d05397ec8a18 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -602,7 +602,7 @@ static int get_string(struct usb_composite_dev *cdev, } } - for (len = 0; s->wData[len] && len <= 126; len++) + for (len = 0; len <= 126 && s->wData[len]; len++) continue; if (!len) return -EINVAL;